Ruby Unicode字符中断JSON编码/解码
我试图将某些内容另存为JSON,但在使用Unicode字符后会出现中断:Ruby Unicode字符中断JSON编码/解码,ruby,json,Ruby,Json,我试图将某些内容另存为JSON,但在使用Unicode字符后会出现中断: Obj: { comment => "test test test £466" } =>到_json会导致 { "comment":"test test test " } Obj.inspectput: `comment => "test test test \243466"` 这里有什么提示吗?听起来丹尼尔有一个使用Iconv的解决方案,即: Iconv.conv('utf-8', 'I
Obj: {
comment => "test test test £466"
}
=>到_json
会导致
{
"comment":"test test test "
}
Obj.inspect
put:
`comment => "test test test \243466"`
这里有什么提示吗?听起来丹尼尔有一个使用Iconv的解决方案,即:
Iconv.conv('utf-8', 'ISO-8859-1', "incoming text")
还有别的办法吗?在我读到有人在heroku上遇到iconv问题时,我用iconv.conv('utf-8','ISO-8859-1','incoming text')转换了传入字符串,然后添加一个答案什么是解决方案并接受它。这样,你的问题就不会像没有答案一样悬而未决了