ID:               47148
 User updated by:  llongo at sata-hts dot com
 Reported By:      llongo at sata-hts dot com
-Status:           Feedback
+Status:           Open
 Bug Type:         Strings related
 Operating System: Linux CentOS 5
 PHP Version:      5.2.8
 New Comment:

Now I've read the documentation about strlen and mb_strlen and the
overloading of strlen. I think my problem is caused by default encoding.
I've soved using mb_strlen($str,"ASCII"), this is not a bug. Thanks for
your attention.


Previous Comments:
------------------------------------------------------------------------

[2009-01-19 12:38:31] [email protected]

I can not reproduce this:

[j...@bfit ~]$ php t.pho 
pack_str: 4
msg: 5
strlen: 9
[j...@bfit ~]$ php -v
PHP 5.2.8 (cli) (built: Jan  8 2009 02:31:38) 
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
[j...@bfit ~]$ uname -a
Linux bfit 2.6.18-92.1.22.el5.centos.plus #1 SMP Wed Dec 17 10:49:19
EST 2008 x86_64 x86_64 x86_64 GNU/Linux
[j...@bfit ~]$ 


------------------------------------------------------------------------

[2009-01-19 11:38:12] llongo at sata-hts dot com

Description:
------------
Passing to strlen a string with a particular sequence of characters
(binary + ascii), strlen returns the wrong number of characters.

The architecture of the host where the problem has happened is x86_64

The php configure is:
./configure --with-openssl --with-zlib --enable-zip --with-pear
--with-
mysql --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-shmop
--enable-pcntl --enable-bcmath --with-apxs
2 --with-gettext --with-gdbm --enable-sockets --enable-mbstring
--with-imap-ssl --with-libdir=lib64

Reproduce code:
---------------
$pack_str = pack("N",240); // binary string
$msg = "<msg>"; // ascii string
echo "pack_str: ".strlen($pack_str)."\n"; // OK
echo "msg: ".strlen($msg)."\n"; // OK
$new_str = $pack_str.$msg;
echo "strlen: ".strlen($new_str)."\n"; // KO

Expected result:
----------------
The expected result of last echo is:
strlen: 9

Actual result:
--------------
The actual result of last echo is:
strlen: 6


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47148&edit=1

Reply via email to