Question

ActiveSupport::Inflector methods like titleize, capitalize, camelize do not work with Cyrillic (Russian, Belarussian, Ukraine, ...) letters.

'xyz'.titleize         
 # => "Xyz"              # OK
'абв'.titleize         
 # => "АБВ"              # FAIL

How can I use ActiveSupport::Inflector methods with Cyrillic letters?

Was it helpful?

Solution

We can use mb_chars to "save" Cyrillic string then ActiveSupport::Inflector methods should work:

'абв'.mb_chars.capitalize.to_s
 => "Абв"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top