[TYPO3-core] RFC #11361: Backend TYPO3 AJAX-Interface: json encoded result empty if it contains non-utf-8 characters

Jeff Segars jsegars at alumni.rice.edu
Wed Sep 16 16:58:09 CEST 2009


Benjamin Mack wrote:
> Hey all,
> 
> this is SVN patch request.
> 
> Branches: 4.2 and trunk
> 
> BT reference: http://bugs.typo3.org/view.php?id=11361
> 
> Type: a classic bug
> 
> Description:
> Currently, in the TYPO3 AJAX interface for the backend there is an 
> option to encode the response that is sent back to the browser via JSON.
> 
> The php-internal function "json_encode" is used for sending back the 
> returned array as a JSON string. However, this function (as documented) 
> works only on UTF-8 encoded data. Test results have proven that if you 
> send json_encode an array with a string that contains non-unicode 
> encoded symbols (like Umlauts in iso-8859-1) that an empty result is 
> returned from this function.
> 
> This basically means that before any data is sent back to the browser 
> via the JSON format that it needs to be converted to Unicode, otherwise 
> the response will be empty.
> 
> Solution:
> Let's check the localCharset (e.g. with forceCharset) if it is unicode 
> before converting the response array to a JSON string. Send the JSON 
> encoded string as UTF-8 then.
> 
> Thus: *every* server call that is returned via JSON needs to be 
> UTF8-encoded. Should probably update the documentation as well then. I 
> will take care of this as well.
> 

I've updated the patch to also account for the inline Javascript 
rendering that was just added in #11819 and committed on behalf of Benni.

Committed attached v2 patch to trunk in r5946.

Thanks for the reviews and testing!
Jeff


More information about the TYPO3-team-core mailing list