json_encode() and non-UTF8 strings

From: Date: Tue, 03 Apr 2012 01:35:36 +0000
Subject: json_encode() and non-UTF8 strings
Groups: php.internals 
Request: Send a blank email to internals+get-59334@lists.php.net to get a copy of this message
Hi internals, I've created a pull request (https://github.com/php/php-src/pull/33) that changes json_encode to fall back to ASCII for strings that are not valid UTF-8. I ran into an issue in a production application involving PayPal IPN callbacks (which are sent encoded as windows-1252) and json_encode(). If there was an accented character present in the data, json_encode() would fail to encode the string and serialize it as 'null'. I've modified the behaviour of the underlying json_escape_string() implementation to attempt to encode strings anyway while still producing a warning. Thanks -- Charlie Somerville

« previous php.internals (#59334) next »