Sorting UTF-8 strings in RoR

前端 未结 7 898
暗喜
暗喜 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:42

    Have you tried accessing the mb_chars method for each of your country strings? mb_chars is a proxy that ActiveSupport adds that defines Unicode safe versions of all the String methods. If the comparator is Unicode-aware then the sorting should work correctly.

    • mb_chars documentation
    0 讨论(0)
提交回复
热议问题