javascript - Ruby on Rails adds additional Backslash to Unicodes read from another CSV -
i have csv file contains unicode characters want display on screen.
here screenshot unicode file.
http://i.imgur.com/lbvxbol.png
here language_controller.rb reads csv , converts json
class languagescontroller < applicationcontroller def availablelanguages = { :data => [] } @language = language.all.each |eachlanguage| availablelanguages[:data] << { :id => eachlanguage.id, :name => eachlanguage.languagename, :csv => [] } csv.foreach(eachlanguage.path) |row| availablelanguages[:data].each |single| single[:csv] << { :keycode => row[0], :unicode => row[1], :chakra => row[2] } end end @data = json.pretty_generate(availablelanguages[:data]) end render json: @data end
end
this adds additional backslash json so, \u091c becomes \u091c. here screenshot response in devtools corresponding rendered json.
http://i.imgur.com/fy0f1l9.png?1
because of this, unicodes displayed text on screen , not read way should be. know character escaping. can have json response include single backslash instead of 2? how?
please help.
javascript ruby-on-rails ruby json unicode
No comments:
Post a Comment