Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29570 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77642 invoked by uid 1010); 19 May 2007 20:58:58 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 77627 invoked from network); 19 May 2007 20:58:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 May 2007 20:58:58 -0000 Authentication-Results: pb1.pair.com header.from=antony@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=antony@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: antony@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from [212.25.124.162] ([212.25.124.162:27637] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CC/84-22488-0156F464 for ; Sat, 19 May 2007 16:58:57 -0400 Received: (qmail 25429 invoked from network); 19 May 2007 20:58:53 -0000 Received: from internal.zend.office (HELO ?127.0.0.1?) (10.1.1.1) by internal.zend.office with SMTP; 19 May 2007 20:58:53 -0000 Message-ID: <464F650B.6090802@zend.com> Date: Sun, 20 May 2007 00:58:51 +0400 User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 To: Tomas Kuliavas CC: internals@lists.php.net References: <51491.88.118.163.159.1179577357.squirrel@avilys.eik.lt> <464EEF4B.1030002@zend.com> <40865.88.118.163.159.1179583186.squirrel@avilys.eik.lt> <464F090A.9090200@zend.com> <35054.88.118.163.159.1179589687.squirrel@avilys.eik.lt> In-Reply-To: <35054.88.118.163.159.1179589687.squirrel@avilys.eik.lt> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP Unicode extension in PHP6 From: antony@zend.com (Antony Dovgal) On 19.05.2007 19:48, Tomas Kuliavas wrote: >> Try this, you'll see it's really easy: >> > //in Unicode mode all strings created this way are Unicode strings >> $s = ""; >> var_dump(strlen(($s))); >> var_dump(strlen((binary)$s)); >> ?> > > http://www.php.net/language.types.type-juggling#language.types.typecasting > > No (binary). > PHP 4.1.2 = parse error in test2.php on line 5. > PHP 5.2.0 = Parse error: syntax error, unexpected T_VARIABLE in test2.php > on line 5 > It is E_PARSE error, so I can't apply fix after detecting PHP6. Yes. We're talking of PHP6 here. > Fix is not portable. We are talking about SquirrelMail code. Minimal PHP > 4.1.x requirement. > > Good fix is closer to > //in Unicode mode all strings created this way are Unicode strings > $s = ""; > var_dump(strlen($s)); > // add php6 test here { > settype($s,'binary'); > // } > var_dump(strlen($s)); > ?> In real life this hack would not be required, since you should/would be using streams returning binary data. My example was just to show how to cast unicode to binary string. > I will have to write wrappers for all affected functions. Not wise. > > strlen("\xC4\x85") = 2. strlen((binary)"\xC4\x85") = 4. Not good. It is > one character in utf-8. I'm afraid I don't understand you again.. > Nevermind. Will watch how PHP6-dev changes and wait for better documentation. Watch? Just watching is pointless. Contribute to the discussions, exchange ideas, help developers - that'll make your life easier eventually. -- Wbr, Antony Dovgal