Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: How to downcase non-English string?

How could I downcase a non-English string in Ruby on Rails 3 ?

str = "Привет"    # Russian  puts str[0].ord   # => 1055 str.downcase! puts str[0].ord   # => 1055 (Should be 1087) 

I want it to work in Ruby 1.8.7 as well as Ruby 1.9.2.

like image 331
Misha Moroshko Avatar asked Sep 11 '11 12:09

Misha Moroshko


1 Answers

str = "Привет" str.mb_chars.downcase.to_s #=> "привет" 
like image 160
fl00r Avatar answered Sep 20 '22 13:09

fl00r