Re: PHP6, UTF & strlen
| From: | Jochem Maas | Date: | Mon, 28 Nov 2005 16:19:09 +0000 |
| Subject: | Re: PHP6, UTF & strlen | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-226548@lists.php.net to get a copy of this message | ||
Jared Williams wrote:
Hi, Just been looking over some code, and saw if (strlen($data) !== file_put_contents($filename, $data)) .... where $data is UTF8, so wondering if this is going to break in PHP6, if so what should be the equivalent code?that currently works with UTF8 strings? or does it only work because you happen to only ever have singlebyte characters in your strings? currently strlen() does not give the expected value on 'multibyte' strings (or strings that contain one or more multibyte chars) which is why the mb_*() functions exist [e.g. mb_strlen()]. In php6 all string functions should work with unicode (I believe its UTF16 internally) transparently and therefore tyhe code you showed should not break BUT rather it should start working ;-) don't hold your breath for php6 - making php unicode native is a complex, difficult undertaking, it will come when its ready - given the snafu's [IMO] surrounding php5.0.5 and php5.1 I hope they take their time. rgds, Jochem
Jared