On 19.05.2007 19:48, Tomas Kuliavas wrote:
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));
?>
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
<?php
//in Unicode mode all strings created this way are Unicode strings
$s = "<any unicode string>";
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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php