Re: json_encode() x-notation

From: Date: Fri, 29 Jun 2018 19:37:09 +0000
Subject: Re: json_encode() x-notation
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-102532@lists.php.net to get a copy of this message
On Fri, Jun 29, 2018 at 1: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? > The TL;DR version AIUI, is that JSON strings are Unicode strings, so any byte sequence in a JSON string must be valid UTF-8. With \x encoding, one could easily create byte sequences which are not valid UTF-8. Best practices tend to use an intermediate, binary-safe encoding (such as base64) when needing to transfer octet streams. -Sara

« previous php.internals (#102532) next »