How do I use String methods on UTF-8 characters?

前端 未结 4 573
心在旅途
心在旅途 2021-01-15 04:48

How do I use String methods on UTF-8 characters?

For example, I have a string with Cyrillic characters, so when I use string.upcase it doesn\'t work.

4条回答
  •  逝去的感伤
    2021-01-15 05:26

    Unfortunately there is no support for downcase/upcase in Ruby 1.9, since the problems described in other posts. Still you can write you own gem, that will add support for cyrillic. You can look at my gem for Polish - turning on proper case folding is as easy as:

    gem 'string_case_pl'
    

    It also provides proper string sorting for Polish.

提交回复
热议问题