ID:               31324
 Updated by:       [EMAIL PROTECTED]
 Reported By:      phpbug at tore dot cc
-Status:           Open
+Status:           Feedback
 Bug Type:         Strings related
 Operating System: Solaris 10
 PHP Version:      5.0.2
 New Comment:

It still works fine for me on Linux. Which compiler did you use to
compile PHP (gcc or sun workshop), and what kind of platform do you
use? intel (32/64), sparc...


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

[2004-12-28 23:40:36] phpbug at tore dot cc

Sorry, my mistake!
It seems to work on one char long strings.
I made a better script (still avoiding loops...).

<?php
$s=pack("C*",0x8e,0x8f);
$t=pack("C*",0x8e);
$u=pack("C*",0x8e,0x8f,0x90);
print "The variable s has the length: " . strlen($s) . "\n";
print "The variable t has the length: " . strlen($t) . "\n";
print "The variable u has the length: " . strlen($u) . "\n";
?>


Result:
The variable s has the length: 1 
The variable t has the length: 1 
The variable u has the length: 2

The result should be:
The variable s has the length: 2 
The variable t has the length: 1 
The variable u has the length: 3

Since s=2 chars, t=1 char and u 3 chars long.

Lets try another test with 7 bit chars.

<?php
$s=pack("C*",0x30,0x31);
$t=pack("C*",0x30);
$u=pack("C*",0x30,0x31,0x32);
print "The variable s has the length: " . strlen($s) . "\n";
print "The variable t has the length: " . strlen($t) . "\n";
print "The variable u has the length: " . strlen($u) . "\n";
?>

Result:
The variable s has the length: 2 
The variable t has the length: 1 
The variable u has the length: 3

As expected. No problem with low values on the chars.

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

[2004-12-28 23:07:29] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.0-win32-latest.zip

Both in 4.3.10RC2, 5.0.3-dev, and 5.1.0-dev it prints as expected:
The variable s has the length: 1 (actual length) 1
So please try a snapshot.

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

[2004-12-28 21:57:50] phpbug at tore dot cc

How about:
<?php
$s=pack("C",143);
$result = count_chars($s, 0);
print "The variable s has the length: " .
           strlen($s) . " (actual length) " . $result[143] .  
           "\n";
?>
Gives printout:
The variable s has the length: 0 (actual length) 1

The 'pack' creates a bit-string with a length of 1 char.
The 'strlen' should should recognize it as a char with length 1. As you
can see below 'strlen' does not only miscalculates the string length for
the char 143.

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

[2004-12-28 19:19:36] [EMAIL PROTECTED]

I don't understand what your script is doing, please come up with a
trivial script instead of those loops.


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

[2004-12-28 18:38:55] phpbug at tore dot cc

My configuration:
./configure  --with-apxs=/opt/csw/apache/bin/apxs --with-mod_charset
--with-openssl=/opt/csw --enable-ftp --with-imap-ssl
--with-jpeg=/usr/csw/lib --with-mysql=/opt/sfw/mysql --with-pgsql
--enable-mbstr-enc-trans --enable-mbstring --enable-mbregex
--with-tiff=/usr/sfc/lib --enable-inline-optimization
--with-imap=/mnt/slask/src/imap-2002 --with-java=/usr/j2se
--with-ming=/usr/local --with-orc8=/opt/oracle
--with-gettext --with-xml --with-dom --with-zlib --enable-cli
--enable-zend-multibyte --with-mod_charset --enable-gd-jis-conv
--disable-libxml

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/31324

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

Reply via email to