Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9285 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

evalJSON ignores charset encoding

Reported by: coffeemug Assigned to: Tobie
Priority: normal Milestone: 2.x
Component: Prototype Version: edge
Severity: normal Keywords:
Cc:

Description

If an application sends unicode characters in X-JSON header, all major browsers treat them as ASCII characters as there is no standard that allows specifying the character encoding of HTTP headers. Updating innerHTML with values obtained from the result of evalJSON then causes incorrect rendering of unicode characters.

The solution described here: http://www.mail-archive.com/rubyonrails-spinoffs@googlegroups.com/msg00508.html works around the problem by calling decodeURIComponent function which processes the text with the encoding specified in the HTTP header.

Shouldn't this be standard in evalJSON?

Change History

08/17/07 06:35:01 changed by Tobie

  • owner changed from sam to Tobie.

"Shouldn't this be standard in evalJSON?"

Certainly not in String#evalJSON, but this could be a good idea for our new headerJSON property of the response object.

10/22/07 11:20:27 changed by tobie

  • status changed from new to closed.
  • resolution set to fixed.

(In [7988]) prototype: Make the Ajax.Response#headerJSON property correctly decode unicode characters. Closes #9285