【发布时间】:2011-01-03 11:06:40
【问题描述】:
是否有在 Ruby 1.8.7(或 Rails 2.x)中使用 String.force_encoding() 的解决方案,以便它像在 Ruby 1.9 中一样工作?我读过一些关于 require active_support 的内容,但这不起作用
$> 宝石列表--local | grep 'rails\|activesupport'
activesupport (3.0.3, 2.3.8, 2.3.5)
rails (2.3.8, 2.3.5)
$> ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10.4.0]
$> rails -v
Rails 2.3.8
irb:
> require "rubygems"
=> true
> require "active_support"
=> true
> "asdf".force_encoding("UTF-8")
NoMethodError: undefined method `force_encoding' for "asdf":String
> String.respond_to?(:force_encoding)
=> false
【问题讨论】:
标签: ruby-on-rails ruby encoding gem