Unicode characters break JSON encode/decode
I'm trying to save something as JSON, but it breaks after a Unicode character:
Obj: {
comment => "test test test £466"
}
=> to_json
results in
{
"comment":"test tes开发者_StackOverflow社区t test "
}
Obj.inspect
puts:
`comment => "test test test \243466"`
Any hints here?
It sounds like Daniel has a solution using Iconv, namely:
Iconv.conv('utf-8', 'ISO-8859-1', "incoming text")
Is there another way to to this though? In another question I read that someone was having trouble with iconv on heroku
精彩评论