Rails: How to downcase non-English string?
str = "Привет"str.mb_chars.downcase.to_s#=> "привет"
Why not to use gem unicode_utils
. This gem will not force downcase
to work, however you can use:
UnicodeUtils.downcase('Привет') #=> 'привет'
If you want to use it easy like this:
> "Привет".downcase=> "привет"
you have to put into initializers folder file string.rb
require 'unicode'class String def downcase Unicode::downcase(self) end def downcase! self.replace downcase end def upcase Unicode::upcase(self) end def upcase! self.replace upcase end def capitalize Unicode::capitalize(self) end def capitalize! self.replace capitalize endend