#45676 [NEW]: The documentation for strlen() is inaccurate

From: Date: Fri, 01 Aug 2008 14:52:36 +0000
Subject: #45676 [NEW]: The documentation for strlen() is inaccurate
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1039@lists.php.net to get a copy of this message
From: mtesta at money-media dot com Operating system: Windows XP PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: The documentation for strlen() is inaccurate Description: ------------ The documentation for strlen() is inaccurate. From my tests it looks like strlen() returns the number of bytes in a string, not the number of characters. Reproduce code: --------------- $str = '€'; echo 'strlen(€) when € is encoded in ANSI (only one byte long): ' . strlen(mb_convert_encoding($str, 'WINDOWS-1252')); echo ' - strlen(€) when € is encoded in UTF-8 (two bytes long): ' . strlen(mb_convert_encoding($str, 'UTF-8')); Expected result: ---------------- strlen(€) when € is encoded in ANSI (only one byte long): 1 - strlen(€) when € is encoded in UTF-8 (only two bytes long): 1 Actual result: -------------- strlen(€) when € is encoded in ANSI (only one byte long): 1 - strlen(€) when € is encoded in UTF-8 (only two bytes long): 2 -- Edit bug report at http://bugs.php.net/?id=45676&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45676&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45676&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45676&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45676&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45676&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45676&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45676&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45676&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45676&r=support Expected behavior: http://bugs.php.net/fix.php?id=45676&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45676&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45676&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45676&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45676&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45676&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45676&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45676&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45676&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45676&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45676&r=mysqlcfg

« previous php.doc.bugs (#1039) next »