[dev] utf-8 string length hack: useful?

Jan Schneider jan at horde.org
Sat Mar 11 01:44:51 PST 2006


Zitat von Chuck Hagenbuch <chuck at horde.org>:

>  From http://www.php.net/manual/en/function.strlen.php#45407
>
> "The easiest way to determine the character count of a UTF8 string is
> to pass the text through utf8_decode() first:
>
> $length = strlen(utf8_decode($s));
>
> utf8_decode() converts characters that are not in ISO-8859-1 to '?',
> which, for the purpose of counting, is quite alright."
>
> I took a quick peek at String.php, but I can't tell offhand if this
> would be useful to us anywhere.

It is, and I already have it on my todo list.
http://pear.php.net/bugs/bug.php?id=7014

Jan.

-- 
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/



More information about the dev mailing list