Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52879 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95689 invoked from network); 4 Jun 2011 04:41:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jun 2011 04:41:03 -0000 Authentication-Results: pb1.pair.com header.from=andrei@zmievski.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=andrei@zmievski.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain zmievski.org from 209.85.161.42 cause and error) X-PHP-List-Original-Sender: andrei@zmievski.org X-Host-Fingerprint: 209.85.161.42 mail-fx0-f42.google.com Received: from [209.85.161.42] ([209.85.161.42:42752] helo=mail-fx0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BC/83-08509-D57B9ED4 for ; Sat, 04 Jun 2011 00:41:02 -0400 Received: by fxm1 with SMTP id 1so1858568fxm.29 for ; Fri, 03 Jun 2011 21:40:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.2.205 with SMTP id 13mr1844263fak.138.1307162457910; Fri, 03 Jun 2011 21:40:57 -0700 (PDT) Received: by 10.223.74.138 with HTTP; Fri, 3 Jun 2011 21:40:57 -0700 (PDT) X-Originating-IP: [98.234.88.127] In-Reply-To: References: <4DE5368A.6050603@moonspot.net> <8BEEEE49-8DA3-4634-BF9C-120F7A15B613@roshambo.org> <4C39B728-2283-49A7-87F5-B0CC9EC42505@bitextender.com> Date: Fri, 3 Jun 2011 21:40:57 -0700 Message-ID: To: =?ISO-8859-1?Q?David_Z=FClke?= Cc: Martin Scotta , Sean Coates , Anthony Ferrara , PHP internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC: Short syntax for Arrays (redux) From: andrei@zmievski.org (Andrei Zmievski) On Fri, Jun 3, 2011 at 3:11 PM, David Z=FClke wrote: > It's not FUD. > > It is different from writing json_decode('=E4\u0123'), because json_decod= e() in PHP only accepts UTF-8 encoded input; > > Give it a shot: > > $chr =3D "\xC3\xA4"; // "=E4" as UTF-8 > var_dump(json_decode('["' . $chr . '\u00e4"]')); > var_dump(json_decode('["' . utf8_decode($chr) . '\u00e4"]')); > ?> > > That'll produce: > >> array(1) { >> =A0 [0]=3D> >> =A0 string(4) "=E4=E4" >> } >> NULL > > Understand what the problem is now? > > If someone does this in a latin1-encoded file: > > > > Then that is valid as a PHP array (as it's a latin1 "=E4", so \xE4), but = cannot be consumed by PHP's json_decode(). And that would be terribly incon= sistent behavior. > > David Of course I know how json_decode() works, David. My question back to you is, do you know how a parser works? Because there's no reason to invoke json_decode() on $fancyNewArray, since it would already be an object, constructed by the Zend parser. The handling of the characters in the key/value strings is exactly the same as in normal object property assignments. -Andrei P.S. Stop being so patronizing.