> 
> 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?

Works with UTF8 strings. Handled nl & fr translations of the PHP Manual fine.
Tried kr & ja, but the docbook srcs coming out of CVS aren't compliant.

> 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()].

strlen() returns the byte count, as does file_put_contents return the number of 
written bytes.

> 
> 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 ;-)

It works now. It'll break of strlen() starts returning character counts, 
instead of byte counts.
 
> 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. 

Not, just that this is one of the few bits of code that could be problematic, 
as the pages are almost competely generated by xslt
extension, therefore avoiding PHP character encoding issues.

Jared

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to