如何在 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
#=> "привет"
关于ruby-on-rails - rails : How to downcase non-English string?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7378069/