Sorting UTF-8 strings in RoR

前端 未结 7 910
暗喜
暗喜 2020-12-09 18:12

I am trying to figure out a \'proper\' way of sorting UTF-8 strings in Ruby on Rails.

In my application, I have a select box that is populated with countries. As my

7条回答
  •  星月不相逢
    2020-12-09 18:24

    The only working solution I found so far (at least for Ruby 1.8 because Ruby 1.9 should handle Unicode better) is Unicode by Yoshida Masato. You can find Unicode.strcmp method there.

    EDIT: Sorry, this solution uses NFD decomposition as well with all its limitations.

提交回复
热议问题