#45676 [Opn->Bgs]: The documentation for strlen() is inaccurate
| From: | rquadling@php.net | Date: | Mon, 04 Aug 2008 12:48:02 +0000 |
| Subject: | #45676 [Opn->Bgs]: The documentation for strlen() is inaccurate | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-1053@lists.php.net to get a copy of this message | ||
ID: 45676
Updated by: rquadling@php.net
Reported By: mtesta at money-media dot com
-Status: Open
+Status: Bogus
Bug Type: Documentation problem
Operating System: Windows XP
PHP Version: Irrelevant
New Comment:
Currently the documentation doesn't reflect the changes coming in PHP6
with regard to unicode strings. In V5 and lower, all strings should be
considered as binary.
Again, there is a user note covering a strlen function for unicode
strings.
Previous Comments:
------------------------------------------------------------------------
[2008-08-01 14:52:35] mtesta at money-media dot com
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 this bug report at http://bugs.php.net/?id=45676&edit=1