Ruby 1.9 doesn't support Unicode normalization yet

前端 未结 7 2277
渐次进展
渐次进展 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 08:19

    String#unicode_normalize, String#unicode_normalize!, String#unicode_normalized? will be introduced in Ruby 2.2. Sample code and implementation can be seen in test case, lib/unicode_normalize.rb and lib/unicode_normalize/normalize.rb.

    // U+00E1: LATIN SMALL LETTER A WITH ACUTE
    // U+U+0301: COMBINING ACUTE ACCENT
    
    puts "\u00E1" == "a\u0301".unicode_normalize(:nfc)
    puts true == "a".unicode_normalized?(:nfc)
    
    0 讨论(0)
提交回复
热议问题