On Fri, Jun 29, 2018 at 8:51 PM, David Rodrigues <david.pro...@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

Reply via email to