Ruby 1.9 尚不支持 Unicode 规范化 [英] Ruby 1.9 doesn't support Unicode normalization yet

查看:49
本文介绍了Ruby 1.9 尚不支持 Unicode 规范化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些旧的 rails 应用程序移植到 Ruby 1.9,但我不断收到有关Ruby 1.9 尚不支持 Unicode 规范化"的警告.我已经追踪到这个函数,但是每个请求我都会收到大约 20 条警告消息:

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 it down to this function, but I'm getting about 20 warning messages per request:

rails-2.3.5/activesupport/lib/active_support/inflector.rb

rails-2.3.5/activesupport/lib/active_support/inflector.rb

def transliterate(string)
  warn "Ruby 1.9 doesn't support Unicode normalization yet"
  string.dup
end

我应该如何开始跟踪并解决这些问题?

Any ideas how I should start tracking these down and resolving it?

推荐答案

如果您知道后果,即重音字符不会在 Ruby 1.9.1 + Rails 2.3.x 中音译,请将其放在 config/initializers 中使警告静音:

If you are aware of the consequences, i.e. accented characters will not be transliterated in Ruby 1.9.1 + Rails 2.3.x, place this in config/initializers to silence the warning:

# http://stackoverflow.com/questions/2135247/ruby-1-9-doesnt-support-unicode-normalization-yet
module ActiveSupport
  module Inflector
    # Calling String#parameterize prints a warning under Ruby 1.9,
    # even if the data in the string doesn't need transliterating.
    if Rails.version =~ /^2\.3/
      undef_method :transliterate
      def transliterate(string)
        string.dup
      end
    end
  end
end

Rails 3 确实解决了这个问题,所以更面向未来的解决方案是朝这个方向迁移.

Rails 3 does indeed solve this issue, so a more future-proof solution would be to migrate towards that.

这篇关于Ruby 1.9 尚不支持 Unicode 规范化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆