# Capitalize and utf8 international symbols

**URL:** <https://www.ruby-forum.com/t/capitalize-and-utf8-international-symbols/185334>\
**Category:** Rails\
**Created:** [March 18, 2010, 12:13pm UTC](https://www.ruby-forum.com/t/capitalize-and-utf8-international-symbols/185334 "2010-03-18T12:13:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/58956e/32.png) [@asoto](https://www.ruby-forum.com/u/asoto)\
**Post date:** [March 18, 2010, 12:13pm UTC](https://www.ruby-forum.com/t/capitalize-and-utf8-international-symbols/185334/1 "2010-03-18T12:13:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![asoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/58956e/32.png) [@asoto](https://www.ruby-forum.com/u/asoto)\
**Post date:** [March 22, 2010, 10:06am UTC](https://www.ruby-forum.com/t/capitalize-and-utf8-international-symbols/185334/2 "2010-03-22T10:06:27Z")

</div>

On Mar 18, 1:12 pm, Alex S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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
