php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51031 strtolower.phpt fails
Submitted: 2010-02-12 20:28 UTC Modified: 2010-02-13 16:45 UTC
From: geissert at debian dot org Assigned: geissert (profile)
Status: Closed Package: Strings related
PHP Version: 5.3SVN-2010-02-12 (snap) OS: Debian GNU/Linux ia64
Private report: No CVE-ID: None
 [2010-02-12 20:28 UTC] geissert at debian dot org
Description:
------------
The test fails with the latest snapshot, 5.3.1 worked fine

Reproduce code:
---------------
echo "*** Testing strtolower() with all 256 chars ***\n";
for ($i=0; $i<=255; $i++){
  $char = chr($i);
  print(bin2hex($char))." => ".(bin2hex(strtolower("$char")))."\n";
}

Expected result:
----------------
*** Testing strtolower() with all 256 chars ***
00 => 00
01 => 01
02 => 02
03 => 03
04 => 04
05 => 05
06 => 06
07 => 07
08 => 08
09 => 09
0a => 0a
0b => 0b
0c => 0c
0d => 0d
0e => 0e
0f => 0f
...
bf => bf
c0 => c0
c1 => c1
c2 => c2
c3 => c3
c4 => c4
c5 => c5
c6 => c6
c7 => c7
c8 => c8
c9 => c9
ca => ca
cb => cb
cc => cc
cd => cd
ce => ce
cf => cf
d0 => d0
d1 => d1
...


Actual result:
--------------
*** Testing strtolower() with all 256 chars ***
00 => 00
01 => 01
02 => 02
03 => 03
04 => 04
05 => 05
06 => 06
07 => 07
08 => 08
09 => 09
0a => 0a
0b => 0b
0c => 0c
0d => 0d
0e => 0e
0f => 0f
...
bf => bf  // error:
c0 => e0
c1 => e1
c2 => e2
c3 => e3
c4 => e4
c5 => e5
c6 => e6
c7 => e7
c8 => e8
c9 => e9
ca => ea
cb => eb
cc => ec
cd => ed
ce => ee
cf => ef
d0 => f0
d1 => f1
d2 => f2
d3 => f3
d4 => f4
d5 => f5
d6 => f6
d7 => d7
d8 => f8
d9 => f9
da => fa
db => fb
dc => fc
dd => fd
de => fe
df => df
e0 => e0 //the rest is fine
...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-12 20:31 UTC] rasmus@php.net
LOCALE?

Ok for me on 64-bit Debian with latest 5.3.3-svn
 [2010-02-12 20:48 UTC] geissert at debian dot org
the test sets LC_ALL to en-US.UTF-8, but playing a bit more with it if I set LANG=C (or to en_US.UTF-8) before calling php it works. If, on the other hand, I set LANG to en_US it fails (this is the case under which I found the bug).

Somehow LANG is being prioritised over LC_ALL.
 [2010-02-12 21:01 UTC] rasmus@php.net
There is no magic here.  All we are doing is calling the low-level 
tolower() function.  I bet you can recreate the same thing with this:

#include <stdio.h>
#include <ctype.h>

void main(void) {
  int ch;
 
  for(ch=0; ch<256; ch++) {
    printf("%x: %x\n",ch,tolower(ch));
  } 
}

 [2010-02-12 21:08 UTC] geissert at debian dot org
Right, got it:

--SKIPIF--
...
  if (!setlocale(LC_ALL, 'en_US.UTF-8', 'en')) {
...

while the test itself does:

  setlocale(LC_ALL, 'en-US.UTF-8');

it should use an underscore instead.
 [2010-02-12 21:17 UTC] rasmus@php.net
Could I encourage you to get an svn account and commit some of these 
trivial fixes yourself?  See http://www.php.net/svn.php and click on 
the "get your own account" link on the left there.
 [2010-02-12 21:38 UTC] geissert at debian dot org
Ok, I just created it. One question: what exactly is the magic to close the bugs from the commit messages? just "\(bug #\d+\)"?
 [2010-02-12 21:47 UTC] rasmus@php.net
Yes, it accepts many formats.  bug #n will work.
Also, if the fix applies to multiple active branches, please commit to 
all branches in a single commit.  The active branches are 
branches/PHP_5_2, branches/PHP_5_3 and trunk
 [2010-02-12 21:47 UTC] johannes@php.net
There's no magic to close, just to add comments. Close has to be done by hand. and your account should work.
 [2010-02-13 16:43 UTC] svn@php.net
Automatic comment from SVN on behalf of geissert
Revision: http://svn.php.net/viewvc/?view=revision&revision=295010
Log: Fix strtolower.phpt (bug #51031)
 [2010-02-13 16:45 UTC] geissert@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 11:01:28 2024 UTC