From:             masakielastic at gmail dot com
Operating system: Mac OSX
PHP version:      5.5.0
Package:          Strings related
Bug Type:         Bug
Bug description:ctype_lower detects non-lower characters

Description:
------------
ctype_lower detects non-lower characters when the local is set to
'en_US.UTF-8' 
on Mac OSX 10.8. This phenomenon cannot't be reproduced on Ubuntu Linux.

This phenomenon means ctype_lower detects Chinese characters and Hangul
(Korean 
Alphabet) which have no concept about lower and upper cases.

The test cases for C language and showing misdetected characters can be
seen 
here: 
https://gist.github.com/masakielastic/5828106

The tests for BSD-compatible OSes are needed judging from Xcode's manual. 

http://developer.apple.com/library/Mac/documentation/Darwin/Reference/ManPages/m
an3/islower.3.html

ctype_upper also detects non-upper characters.

Test script:
---------------
$expected = [];
$result = [];
 
for ($i = 0; $i <= 0xFF; ++$i) {
 
    setlocale(LC_ALL, 'C');
    if (ctype_lower(chr($i))) {
        $expected[] = $i;
    }
 
    setlocale(LC_ALL, 'en_US.UTF-8');
    if (ctype_lower(chr($i))) {
        $result[] = $i;
    }
 
}
 
var_dump(
    [] === array_diff($result, $expected)
);

Expected result:
----------------
bool(true)

Actual result:
--------------
bool(false)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=65080&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65080&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=65080&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=65080&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=65080&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=65080&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=65080&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=65080&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=65080&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=65080&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=65080&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=65080&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=65080&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=65080&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65080&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=65080&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=65080&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=65080&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65080&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=65080&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65080&r=mysqlcfg

Reply via email to