Capitalize and utf8 international symbols

Hi there,

Being a relatively happy Rails user I suddenly noticed that
string#capitalize and friends do not play well with international
characters well. Sample console session:

$ ./script/console
Loading development environment (Rails 2.2.3)

$KCODE
=> “UTF8”

“ÑÂÌÏËÏ”.capitalize
=> “ÑÂÌÏËÏ”

Where “ñÂÌÏËÏ” was expected (Russian word for “Apple”).

I’ve googled for a workaround and found this:

“ÑÂÌÏËÏ”.mb_chars.capitalize.to_s
=> “ñÂÌÏËÏ”

but does it really need to be so ugly? Everyone else doing this?

I’m on Ubuntu 9.10 with Rails-2.2.3 and ruby-1.8.7.


Cheers,
Alex

On Mar 18, 1:12 pm, Alex S. [email protected] wrote:

but does it really need to be so ugly? Everyone else doing this?

I’m on Ubuntu 9.10 with Rails-2.2.3 and ruby-1.8.7.

Sadly, google groups scrambled the symbols, but take my word – it
doesn’t work with plain capitalize, but works only through mb_chars.

Am I doing something wrong? Can I (should I) monkey-patch String
class to pipe capitalize et al. through mb_chars?


Regards,
Alex