ID: 42063
Updated by: [EMAIL PROTECTED]
Reported By: jo at feuersee dot de
-Status: Open
+Status: Wont fix
Bug Type: I18N and L10N related
Operating System: Linux
PHP Version: 5.2.3
New Comment:
PHP 6 will have support for this. Won't change with PHP 5.
Previous Comments:
------------------------------------------------------------------------
[2007-07-21 20:27:37] jo at feuersee dot de
Description:
------------
I stumbled about this issue while debugging a project which uses PEAR
XML_Parser which relys on the assumption that strtoupper() works for all
US-ASCII characters no matter which locale or encoding.
Unfortunately, it does not.
This has been discussed in PHP bugs
22003
21771
35583
The letter i isn't converted to I by strtoupper() when the locale is
set to turkish (via setlocale(LC_ALL, 'tr_TR'))
However, the letter i is converted to I by strtoupper() when the locale
is set to turkish (via setlocale(LC_ALL, 'tr'))
mb_strtoupper() does work under all encodings.
Now, despite blaming the Unicode guys or the turkish language or
whatever:
How are we supposed to code properly under these circumstances?
My proposal:
strtoupper/lower() claim to be locale aware, but they really aren't
(try to upperchase umlaut äöü under locale de_DE - doesn't work at all).
Thus, redefining these functions to work for 7-bit encoded (US-ASCII)
data _only_ won't change anything. Skip the locale dependency, then the
locale tr_TR will work.
Reproduce code:
---------------
[EMAIL PROTECTED] ~> php -r 'setlocale(LC_ALL, "tr"); $text = "begin";
printf("%s
%s\n", strtoupper($text), bin2hex(strtoupper($text))); '
BEGIN 424547494e
[EMAIL PROTECTED] ~> php -r 'setlocale(LC_ALL, "tr_TR"); $text = "begin";
printf("%s %s\n", strtoupper($text), bin2hex(strtoupper($text))); '
BEG�N 424547dd4e
[EMAIL PROTECTED] ~> php -r 'setlocale(LC_ALL, "tr_TR.UTF-8"); $text = "begin";
printf("%s %s\n", strtoupper($text), bin2hex(strtoupper($text))); '
BEGiN 424547694e
Expected result:
----------------
BEGIN 424547494e
(for all locales)
Actual result:
--------------
(see above)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42063&edit=1