Re: json_encode() x-notation

From: Date: Wed, 04 Jul 2018 22:01:52 +0000
Subject: Re: json_encode() x-notation
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-102590@lists.php.net to get a copy of this message
On Fri, Jun 29, 2018 at 8:51 PM, David Rodrigues <david.proweb@gmail.com> wrote: > ​Hello. I saw that JS supports the x-notation (\x40) and u-notation > (\u0040), but PHP only supports u-notation. There some reason for that? > > JSON.parse('"\x40"'); // => @ > JSON.parse('"\u0040"'); // => @ > No it doesn't. JSON.parse() will correctly reject \x escapes because they aren't valid JSON. You are using a normal JS string (which has nothing to do with JSON and supports \x), which will unescape \x before JSON.parse() ever sees it. If you write JSON.parse('"\\x40"') or similar, you will get an error. Nikita

« previous php.internals (#102590) next »