Re: json_encode() x-notation
| From: | David Rodrigues | Date: | Wed, 04 Jul 2018 23:28:33 +0000 |
| Subject: | Re: json_encode() x-notation | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-102596@lists.php.net to get a copy of this message | ||
Em qua, 4 de jul de 2018 19:01, Nikita Popov <nikita.ppv@gmail.com>
escreveu:
> 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.
>
Oh! You are right. I just forgot to test this case. :D Topic is closed if
no one have no more to say, so.
> Nikita
>