On Fri, Jun 3, 2011 at 3:11 PM, David Zülke <david.zue...@bitextender.com> wrote: > It's not FUD. > > It is different from writing json_decode('ä\u0123'), because json_decode() in > PHP only accepts UTF-8 encoded input; > > Give it a shot: > > <?php > $chr = "\xC3\xA4"; // "ä" as UTF-8 > var_dump(json_decode('["' . $chr . '\u00e4"]')); > var_dump(json_decode('["' . utf8_decode($chr) . '\u00e4"]')); > ?> > > That'll produce: > >> array(1) { >> [0]=> >> string(4) "ää" >> } >> NULL > > Understand what the problem is now? > > If someone does this in a latin1-encoded file: > > <?php $fancyNewArray = {"yay": "ä"}; ?> > > Then that is valid as a PHP array (as it's a latin1 "ä", so \xE4), but cannot > be consumed by PHP's json_decode(). And that would be terribly inconsistent > behavior. > > David
Of course I know how json_decode() works, David. My question back to you is, do you know how a parser works? Because there's no reason to invoke json_decode() on $fancyNewArray, since it would already be an object, constructed by the Zend parser. The handling of the characters in the key/value strings is exactly the same as in normal object property assignments. -Andrei P.S. Stop being so patronizing. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php