2

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 test test "
}

Obj.inspect puts:

`comment => "test test test \243466"`

Any hints here?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Daniel
  • 21
  • 2
  • Nevermind, I converted the incoming string with Iconv.conv('utf-8', 'ISO-8859-1', "incoming text") – Daniel Jun 05 '11 at 01:54
  • 1
    Then add an answer what is the solution and accept it. That way, your question won't hang around as unanswered. ;) – dimitarvp Jun 14 '11 at 12:06

1 Answers1

1

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

Community
  • 1
  • 1
Kevin Davis
  • 2,698
  • 1
  • 22
  • 27