Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102590 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24868 invoked from network); 4 Jul 2018 22:01:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jul 2018 22:01:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.174 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.223.174 mail-io0-f174.google.com Received: from [209.85.223.174] ([209.85.223.174:36438] helo=mail-io0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EC/39-55607-3D34D3B5 for ; Wed, 04 Jul 2018 18:01:56 -0400 Received: by mail-io0-f174.google.com with SMTP id k3-v6so5949211iog.3 for ; Wed, 04 Jul 2018 15:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=yibg/f3UrHs27HGAGWiCJdAdteScv61xFElcI2FoDVY=; b=QZy6qtI8dgRS223gEYpFVCjTa6DOD/vqnMSggN3C4EI15XpJtAiEN/Wkb2EVWUKGFJ 6yalD0KNfH+xSHuaP+3ectjFheqqT0Dr6Kpe6HHPadsEOu+8/k2JueUy870Hbit7vABU WC6VahYzMyGsjig+/XuKvsjcLUTq971h7tlx/BJksyhElKELg9ieWhbhls3yfkVz+HOc XehE1YvSCBdpAac+dtc2eJ483EtzZFQR8vOdIJMMw+KZkSLoe+rwJYzqhnzoHgc81PED p79L1QmPC8QVOFwk2CJUP97zXfhLeJxF1iXRWSL0OSmkpHm6xUA/p+DcllOb8EHGDIbI E/1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=yibg/f3UrHs27HGAGWiCJdAdteScv61xFElcI2FoDVY=; b=NGekU162xHWGycneW21LP9iQoVvLyl2j3BcL1aMZZIXnuqJJu0lgtjcjKGn2h5Wj1Y 3bIZ9ud0VJOZi0xmmpTAN2E2FJVZoLPeH4ryulvSHRgujmNnPjCNE7z4Ylj+tZT/Snjr U3fNUrIVIfHY8IMUPmv8vi/QX8YZDRInh4GlUHLTdgWXenBNHTE8TSozr1RoSrxqNu1T uKpLovGvpG952upCIylTktYhQXGsuJtCtttCj3JXgwJCuP+GYcVeK7qZhOkEb1Uu/vWK 9YZo9q5IcxCk64+7B+lRjF8yIGI3hzO990mgmdrOu771o4bhWoxtdigFAyefWrP0v0Hs /OxA== X-Gm-Message-State: APt69E1/XSqoPfKjHJJadzmZQsuTM5CX/EOLhWLPMKGpIuBsVIk/S4Fn MoQ9dCEP1DrJ6ChoiZ//LXb1KCZ6U3GQa0LGG28= X-Google-Smtp-Source: AAOMgpcooyb0PAAplWB2mSBRFd7Ydlq5Dv85hdHQCytPojTtscy5Hn4ScxFZ3nvdoYpXZac1E7PBdwooG++uEiPH7KE= X-Received: by 2002:a6b:c844:: with SMTP id y65-v6mr2873404iof.187.1530741712594; Wed, 04 Jul 2018 15:01:52 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:148a:0:0:0:0:0 with HTTP; Wed, 4 Jul 2018 15:01:52 -0700 (PDT) In-Reply-To: References: Date: Thu, 5 Jul 2018 00:01:52 +0200 Message-ID: To: David Rodrigues Cc: PHP Internals Content-Type: multipart/alternative; boundary="00000000000005ada9057033948a" Subject: Re: [PHP-DEV] json_encode() x-notation From: nikita.ppv@gmail.com (Nikita Popov) --00000000000005ada9057033948a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jun 29, 2018 at 8:51 PM, David Rodrigues wrote: > =E2=80=8BHello. I saw that JS supports the x-notation (\x40) and u-notati= on > (\u0040), but PHP only supports u-notation. There some reason for that? > > JSON.parse('"\x40"'); // =3D> @ > JSON.parse('"\u0040"'); // =3D> @ > 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 --00000000000005ada9057033948a--