문제

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?

도움이 되었습니까?

해결책

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

'абв'.mb_chars.capitalize.to_s
 => "Абв"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top