#39993 [Asn->Csd]: tr_TR.UTF-8 locale has problems with PHP

From: Date: Thu, 18 Jan 2007 23:20:31 +0000
Subject: #39993 [Asn->Csd]: tr_TR.UTF-8 locale has problems with PHP
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-107744@lists.php.net to get a copy of this message
ID: 39993 Updated by: iliaa@php.net Reported By: tunix at raptiye dot org -Status: Assigned +Status: Closed Bug Type: Date/time related Operating System: Arch Linux PHP Version: 5.2.0 Assigned To: derick New Comment: This bug has been fixed in CVS. 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. Previous Comments: ------------------------------------------------------------------------ [2007-01-01 13:38:28] tokul at users dot sourceforge dot net Issue is not fixed in 5.2.x snapshots (200701011130). You are using locale dependent case insensitive lookups and assume locale independent case sensitivity rules. In Turkish locale 'latin small i' is not same thing as 'latin capital i'. Turks have different case sensitivity rules. Reproduce code (TZ='Europe/Helsinki' /usr/bin/php /path/test-locale.php): --- <?php var_dump(setlocale(LC_ALL,'tr_TR.UTF-8')); var_dump(date_default_timezone_get()); var_dump(setlocale(LC_CTYPE,0)); --- Expected result: --- string(11) "tr_TR.UTF-8" string(15) "Europe/Helsinki" string(11) "tr_TR.UTF-8" --- Second line depends on default timezone setting. Make sure that you have 'i' symbol in timezone name. Actual result (PHP 5.2.0-8 debian and PHP 5.2.1RC2-dev snapshot): --- string(11) "tr_TR.UTF-8" Fatal error: date_default_timezone_get(): Timezone database is corrupt - this should *never* happen! in /path/test-locale.php on line 3 --- Patch by iliaa@php.net is not correct, because it does not preserve existing LC_CTYPE value and makes all strtolower/strtoupper calls locale independent when PHP manual states that these calls are locale dependent. Result after Iliaa's patch is applied: --- string(11) "tr_TR.UTF-8" string(15) "Europe/Helsinki" string(1) "C" --- ------------------------------------------------------------------------ [2006-12-30 23:45:52] iliaa@php.net Another option that is a bit more performance friendly is something like this: http://bb.prohost.org/patch/date.txt ------------------------------------------------------------------------ [2006-12-30 23:08:23] tony2001@php.net Its is reproducible with the snapshot. I believe this happens because of strcasecmp() (used in seek_to_tz_position()) behaving weird with tr_TR locale (I remember some similar problems in the past), using something like tolower() & memcmp() should do the trick. ------------------------------------------------------------------------ [2006-12-30 20:46:30] derick@php.net Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.2-win32-latest.zip ------------------------------------------------------------------------ [2006-12-30 18:22:08] tunix at raptiye dot org Description: ------------ I type <?php echo date("l"); ?> into an empty php file and then run it in command line prompt, and it prints this error message: Fatal error: date(): Timezone database is corrupt - this should *never* happen! in Command line code on line 1 If I use tr_TR.UTF-8 locale, then I can produce this error. But if I use tr_TR.ISO8859-9 or C locales, it doesn't print the error message. Although, tr_TR.ISO8859-9 and C locales return Saturday which is English. It should return "Cumartesi" (turkish). GNU date command works fine with UTF-8 locale. [19:07] (tunix@penguix ~)$ TZ=Europe/Istanbul LANG=tr_TR.UTF-8 date +%A Cumartesi Reproduce code: --------------- [19:06] (tunix@penguix ~)$ TZ=Europe/Istanbul LANG=tr_TR.UTF-8 php -r ‘date(”l”);’ Fatal error: date(): Timezone database is corrupt - this should *never* happen! in Command line code on line 1 Expected result: ---------------- It's supposed to be: [19:06] (tunix@penguix ~)$ TZ=Europe/Istanbul LANG=tr_TR.UTF-8 php -r ‘date(”l”);’ Cumartesi ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39993&edit=1

« previous php.bugs (#107744) next »