将UTF-8字符串转换为可读字符串

时间:2016-07-08 12:41:44

标签: ruby-on-rails ruby utf-8

我有一个UTF-8字符串,如:

NA

并希望转换为a= "for ccps ‘the way forward’"

我尝试过代码:

for CCPs ‘the way forward’

1 个答案:

答案 0 :(得分:0)

终于得到了解决方案:

a= "for ccps ‘the way forward’"
a.encode("cp1252").force_encoding("utf-8")