Reply to RE: [PHP] PHP6, UTF & strlen

Your name:

Reply:


Posted by "Jared Williams" on 11/28/05 19:27

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация