Ruby 1.9 doesn't support Unicode normalization yet

前端 未结 7 2272
渐次进展
渐次进展 2021-01-04 07:46

I\'m trying to port over some of my old rails apps to Ruby 1.9 and I keep getting warnings about how \"Ruby 1.9 doesn\'t support Unicode normalization yet.\" I\'ve tracked

7条回答
  •  有刺的猬
    2021-01-04 07:58

    The StringEx Gem seems to work pretty well. It has no dependency on Iconv either.

    It adds some methods to the String class, like "to_ascii" which does beautiful transliteration out of the box:

    require 'stringex'
    "äöüÄÖÜßë".to_ascii #=> "aouAOUsse"
    

    Also, the Babosa Gem does a great job transliterating UTF-8 strings, even with language support:

    "Jürgen Müller".to_slug.transliterate.to_s           #=> "Jurgen Muller"
    "Jürgen Müller".to_slug.transliterate(:german).to_s  #=> "Juergen Mueller"
    

    Enjoy.

提交回复
热议问题