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

Chuck Hagenbuch chuck at horde.org
Fri Mar 10 14:12:28 PST 2006


 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.

-chuck

-- 
"we are plastered to the windshield of the bus that is time." - Chris


More information about the dev mailing list