Bug #66108 [Opn->Nab]: Setting locale to 'tr_TR' lowercases parts of constants

From: Date: Wed, 01 Apr 2015 21:06:43 +0000
Subject: Bug #66108 [Opn->Nab]: Setting locale to 'tr_TR' lowercases parts of constants
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191772@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66108&edit=1

 ID:                 66108
 Updated by:         stas@php.net
 Reported by:        t dot baumgarden at web dot de
 Summary:            Setting locale to 'tr_TR' lowercases parts of
                     constants
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   CentOS 6
 PHP Version:        5.5.6
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

This is not the same as #18556 as you are manually using "strtoupper", which is
locale-dependent, so it does what you asked it to do - provides the locale-dependent uppercase
rendering of "production". Unfortunately, in tr_TR the uppercase of "production"
is "PRODUCTİON" and not "PRODUCTION". If you must use this locale, I'd
suggest using mb_strtoupper or mb_convert_case.


Previous Comments:
------------------------------------------------------------------------
[2015-02-26 10:56:07] jpauli@php.net

PHP's strtolower() has always been locale aware and works the same in 5.4 and 5.5.
Did I miss something ?

------------------------------------------------------------------------
[2014-09-10 15:04:32] chuanm at gmail dot com

The bug doesn't exist in php 5.4.31. So it could be introduced in php 5.5. The nasty part of
this bug is that a locale change would affect how php handles some "English" letter.

------------------------------------------------------------------------
[2014-09-10 14:51:13] chuanm at gmail dot com

I think this bug also affects preg_match() function while using the case insensitive match modifier.
Seems only letter 'i' has the problem. See example below: 

<?php

setlocale(LC_ALL, 'tr_TR.UTF-8');
var_dump(preg_match('/I/i', 'production'));   // output: no match found (WRONG)
var_dump(preg_match('/O/i', 'production'));   // output: one match found
(correct)

------------------------------------------------------------------------
[2013-11-17 18:57:47] t dot baumgarden at web dot de

In short:

setlocale(LC_ALL, 'tr_TR.UTF-8');
echo strtoupper('production');

Result: "PRODUCTiON" with wrong "i"

------------------------------------------------------------------------
[2013-11-17 18:41:21] t dot baumgarden at web dot de

Description:
------------
Hi. The (same?) bug was closed long time before here: https://bugs.php.net/bug.php?id=18556

Now its back in php 5.5.6.

Write

setlocale(LC_ALL, 'tr_TR.UTF-8');

I get:

constant(): Couldn't find constant test::PRODUCTiON

and complete page is broken.

See "i" in "PRODUCTiON". Change 'tr_TR.UTF-8' to another string like
'en_US.UTF-8' now its working fine.

Test script:
---------------
class test {
	const PRODUCTION  = 20;
    public static $environment = 10;
}
test::$environment = constant('test::'.strtoupper('production'));
echo (test::$environment);


Expected result:
----------------
20

Actual result:
--------------
Error message: constant(): Couldn't find constant test::PRODUCTiON


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



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


Thread (7 messages)

« previous php.bugs (#191772) next »