如何在Ruby on Rails 3中对非英语字符串进行降级?
str = "Привет" # Russian
puts str[0].ord # => 1055
str.downcase!
puts str[0].ord # => 1055 (Should be 1087)
我希望它能在Ruby 1.8.7和Ruby 1.9.2中运行.
如何在Ruby on Rails 3中对非英语字符串进行降级?
str = "Привет" # Russian
puts str[0].ord # => 1055
str.downcase!
puts str[0].ord # => 1055 (Should be 1087)
我希望它能在Ruby 1.8.7和Ruby 1.9.2中运行.
str = "Привет"
str.mb_chars.downcase.to_s
#=> "привет"