Re: PHP Unicode extension in PHP6

From: Date: Sat, 19 May 2007 14:26:18 +0000
Subject: Re: PHP Unicode extension in PHP6
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-29558@lists.php.net to get a copy of this message
On 19.05.2007 17:59, Tomas Kuliavas wrote:
SquirrelMail scripts are designed to work with binary strings. They will have to deal with emails written in many different character sets. In some cases scripts must know string length in bytes and not in symbols. If PHP starts converting email body or message parts, strings won't match information stored in email headers.
Try this, you'll see it's really easy: <?php //in Unicode mode all strings created this way are Unicode strings $s = "<any unicode string>"; var_dump(strlen(($s))); var_dump(strlen((binary)$s)); ?>
If unicode.semantics are turned on, PHP6-dev breaks one time pad creation and randomizing of mt_rand. crc32, base64_encode and fputs notices and warnings. "function expects parameter 1 to be strictly a binary string, Unicode string given". "x character unicode buffer downcoded for binary stream runtime_encoding". I might provide sample code, if I find the way to reduce existing code to something simple. Currently I am trying to understand what exactly is broken in SquirrelMail functions.
I don't think there is something broken. You just pass unicode string to the functions which expected only binary ones.
I can fix these issues, but one day PHP might add similar checks to str_replace(), array functions and pcre extension. Then it will break character set conversion functions and any other code that operates with 8bit strings. Currently I am stuck on broken authentication and can't check if other parts of interface are already broken. I could not find the way to disable unicode.semantics in the script.
Sure, that's not possible.
PHP_INI_PERDIR is not an option for scripts that are designed to be portable. In some cases end user can't use .htaccess and can't control php.ini or httpd.conf. mbstring function overloading effects can be disabled. The way to turn off unicode.semantics is not documented. If mbstring.func_overload is turned on, I can't trust string functions. Same thing happens when unicode.semantics are turned on.
-- Wbr, Antony Dovgal

« previous php.internals (#29558) next »