ID:               51031
 Comment by:       geissert at debian dot org
 Reported By:      geissert at debian dot org
 Status:           Open
 Bug Type:         Strings related
 Operating System: Debian GNU/Linux ia64
 PHP Version:      5.3SVN-2010-02-12 (snap)
 New Comment:

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.


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

[2010-02-12 21:01:58] ras...@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 20:48:30] 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 20:31:03] ras...@php.net

LOCALE?

Ok for me on 64-bit Debian with latest 5.3.3-svn

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

[2010-02-12 20:28:33] 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
...


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


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

Reply via email to