Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29871 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72862 invoked by uid 1010); 29 May 2007 15:31:56 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 72840 invoked from network); 29 May 2007 15:31:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 May 2007 15:31:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@googlemail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 66.249.82.236 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@googlemail.com X-Host-Fingerprint: 66.249.82.236 wx-out-0506.google.com Linux 2.4/2.6 Received: from [66.249.82.236] ([66.249.82.236:59736] helo=wx-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E1/3C-08609-E574C564 for ; Tue, 29 May 2007 11:31:46 -0400 Received: by wx-out-0506.google.com with SMTP id i28so1239571wxd for ; Tue, 29 May 2007 08:30:22 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=googlemail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=fVsN81Uovnob7vqrMp7pownUWVRZtu3UyU1MUQp46VAaPUP19fvbJJ1SrCvgd0ojkxWS08UlLvO13y+N9fpUPCuUS4mcUA08b6dUsTAlQTnzVKHD9isq3CjhGU57F2I0jnsanle3kqa8Jm+bXYsMFm4NeJCPUpknK9McC+ZqjXw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=beta; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=k/KNGCcbV3Zed9lmNTn51Q4ljS+NntktGGMuhPWCj8xwcPBQXXddWKlz57htGOzA/NAHYXld79Lgu/+ifZWiSlsPrSaecLR03W08hfVv2vxdZIvSeKF0nE43LMBe0kTw02kBA+5PgCO1O3WHODGo4LzHLeVgFWcap2uMYdfHhE8= Received: by 10.90.68.15 with SMTP id q15mr4846029aga.1180452622202; Tue, 29 May 2007 08:30:22 -0700 (PDT) Received: by 10.90.84.3 with HTTP; Tue, 29 May 2007 08:30:22 -0700 (PDT) Message-ID: <10845a340705290830y337a050amfc3cac12a66eb1b7@mail.gmail.com> Date: Tue, 29 May 2007 16:30:22 +0100 Reply-To: RQuadling@GoogleMail.com To: Pierre Cc: "David Coallier" , "Antony Dovgal" , php-dev In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <465BF195.2080300@zend.com> Subject: Re: [PHP-DEV] bitwise operations and Unicode strings From: rquadling@googlemail.com ("Richard Quadling") As PHP is loosely typed, "1"==1 is fine. Is it that with Unicode, this looseness is gone? On 29/05/07, Pierre wrote: > Hi, > > On 5/29/07, David Coallier wrote: > > On 5/29/07, Antony Dovgal wrote: > > > Hello. > > > > > > Do you think the engine should support bitwise operators and Unicode strings? > > > If yes, how do you think it should work? > > > > > > Example: > > > > > $a = "1"; > > > $a|="2"; > > > var_dump($a); > > > ?> > > > > > > This code outputs "3" in native mode and "Fatal error: Unsupported operand types" in Unicode mode. > > > I believe this is an inconsistency and it should be possible to use Unicode strings there. > > > > Definitely > > > > > > > > There are several possible ways to implement it: > > > 1) the same as with native strings - apply the operator to each element of the string separately; > > > 2) convert the string to binary (using say iso-8859-1) and then see 1); > > > > I would probably be for the solution #2 and of course using the > > unicode.runtime_encoding ini setting to convert it to binary. > > > > > > > > > > We can also leave it as is (since it doesn't seem very useful) or even drop the native strings support (it doesn't seem very useful to me either). > > > > I think this is a bad choice.. might not be useful to you, but might > > be to some other people > > I fail to see or imagine any useful usages for such hacks. Laziness > justifies it with binary strings (as in 5.x), but as long as an > unicode string is given, one should really first cast to integer > before using it with a bitwise operator (or any other non string > operation). > > I'm in favour of keeping the current behaviors and drop the native > support as well for consistency (and documentation/wtf headaches). > > --Pierre > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"