# Problem with case statement and mb\_chars in Ruby-1.9.2

**URL:** <https://discuss.rubyonrails.org/t/problem-with-case-statement-and-mb-chars-in-ruby-1-9-2/55648>\
**Category:** rubyonrails-talk\
**Created:** [November 10, 2010, 5:58pm UTC](https://discuss.rubyonrails.org/t/problem-with-case-statement-and-mb-chars-in-ruby-1-9-2/55648 "2010-11-10T17:58:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [November 10, 2010, 5:58pm UTC](https://discuss.rubyonrails.org/t/problem-with-case-statement-and-mb-chars-in-ruby-1-9-2/55648/1 "2010-11-10T17:58:41Z")

</div>

RoR-3.0.1

I have this case statement:

&nbsp;&nbsp;case n.hll\_normalize &nbsp;&nbsp;&nbsp;&nbsp;when "common name" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@my\_correspondent.correspondent\_common\_name = s &nbsp;&nbsp;&nbsp;&nbsp;when "legal name" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;. . . &nbsp;&nbsp;&nbsp;&nbsp;else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;raise ArgumentError, "#{n} attribute is not provided for." &nbsp;&nbsp;end

hll\_normalize is defined as:

&nbsp;&nbsp;def hll\_normalise &nbsp;&nbsp;&nbsp;&nbsp;strip.squeeze(" ").mb\_chars.downcase &nbsp;&nbsp;end

I pass this case statement this value for n: "common name"

When run with Ruby-1.8.7p302 this works. The exact same code run with Ruby-1.9.2p0 yields:

common name attribute is not provided for. (ArgumentError)

When I enter rails console then I see this:

$ rails c Loading development environment (Rails 3.0.1) ruby-1.9.2-p0 \> x = "common name" =\> "common name" ruby-1.9.2-p0 \> x.mb\_chars =\> common name ruby-1.9.2-p0 \> x.mb\_chars.downcase =\> common name ruby-1.9.2-p0 \> "common name" == x.mb\_chars.downcase =\> true ruby-1.9.2-p0 \> "common name" == x.strip.squeeze(" ").mb\_chars.downcase =\> true ruby-1.9.2-p0 \> case x.strip.squeeze(" ").mb\_chars.downcase ruby-1.9.2-p0 ?\> when "uncommon" then puts "nothing" ruby-1.9.2-p0 ?\> when "common name" then puts x ruby-1.9.2-p0 ?\> end =\> nil ruby-1.9.2-p0 \>

So, what is the case statement sensitive wrt mb\_chars that changes the result of "common name" == x.strip.squeeze(" ").mb\_chars.downcase when used as an argument? Is there a nil coming back from somewhere in the case statement argument evaluation when mb\_chars is involved?

This is definitely related to mb\_chars because this works:

ruby-1.9.2-p0 \> case x.strip.squeeze(" ").downcase ruby-1.9.2-p0 ?\> when "uncommon" then puts "nothing" ruby-1.9.2-p0 ?\> when "common name" then puts x ruby-1.9.2-p0 ?\> end common name =\> nil ruby-1.9.2-p0 \>
