Reputation: 103733
I've got problem with UTF8 string exported using to_json.
The problem is that when I do this:
ruby-1.9.2-p290 :005 > "anche il più remoto".encoding
=> #<Encoding:UTF-8>
ruby-1.9.2-p290 :006 > {:text => "anche il più remoto"}.to_json
=> "{\"text\":\"anche il pi\\u00f9 remoto\"}"
{:text => "anche il più remoto"}.to_json.encoding
=> #<Encoding:US-ASCII>
ruby-1.9.2-p290 :009 >
How can i skip changing the encoding? I want to return UTF8 string to the clients so they don't have decode it.
Upvotes: 1
Views: 1132