I had my app running in ruby 1.8.7 and rails 3.0.11 ,I upgraded it with 1.9.2 ruby and rails 3.2.2. it has a utf convertor like this
@utf8_converter = Iconv.new('UTF-8//IGNORE', 'UTF-8')
......
......
def utf8(untrusted_string)
valid_string = @utf8_converter.iconv(untrusted_string + ' ')[0..-2]
return valid_string
Unto my Understanding Iconv doesn't support ruby 1.9.2. how can make it run?
Thanks
I believe this is should get you on the right track:
def utf8(untrusted_string)
valid_string = (untrusted_string + ' ').encode('utf-8')
return valid_string
end
The @utf8_converter
variable is no longer needed as Iconv is deprecated, so you can get away with just your utf8 method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.