开发者

Rails Json response encoding

开发者 https://www.devze.com 2023-01-20 23:26 出处:网络
I\'ve a rails controller that respond_to JSON with a wrong encoding. The site is correctly setup with UTF-8 encoding and the database as well.

I've a rails controller that respond_to JSON with a wrong encoding. The site is correctly setup with UTF-8 encoding and the database as well. The text in my db is well formatted, but in the JSON response, all special characters are set to \ufffd.开发者_C百科 How can I solve the problem?


Everyone running on Ruby 1.9.x and using MySQL, should use the mysql2 gem. It forces the use of UTF-8 and converts to/from UTF-8 automatically when needed.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号