Live data from Hacker News

PHP Bug #18556 : Setting locale to 'tr_TR' lowercases class names

bugs.php.net

11–20 of 135 posts

Re: PHP Bug #18556 : Setting locale to 'tr_TR' lowercases class names

#11
PHP is a big legacy open source project, worked on by many volunteers whenever they can spare the time, just like any other open source project.

It is wildly successful despite this and many other bugs.

I only wish that the people who spend as much time attacking PHP and it's developers endlessly would instead focus some of that energy into helping to improve PHP, but I guess some of us are just negatively charged.

Sad that we have yet another anti-PHP posting hitting the front of HN in as many days, let the hating re-commence (again)...

Re: PHP Bug #18556 : Setting locale to 'tr_TR' lowercases class names

#12
post #2

Words fail me.

I know it seems insane, but Turkish capitalization is not fun to work with as a programmer. When they latinized the alphabet 100 years ago or so, they were short on vowels and so it must have seemed pretty clever and convenient to make i and I separate letters with İ and ı respective case pairs. From a western programmers perspective though it's one of the worst unicode special cases owing to its combined unexpectedness and commonness.

Just as an example, text-transform: uppercase has been broken in Turkish for all major browsers until I believe Firefox finally fixed it late last year, after having a bug open for nearly a decade.

Re: PHP Bug #18556 : Setting locale to 'tr_TR' lowercases class names

#13
I think this was a good explanation:

"No, the problem results because lowercase i (in most languages) and uppercase I (in most languages) are not actually considered to be the upper/lower variant of the same letter in Turkish. In Turkish, the undotted ı is the lowercase of I, and the dotted İ is the uppercase of i. If you have a class named Image, it will break if the locale is changed to turkish because class_exists() function uses zend_str_tolower(), and changes the case on all classes, because they are supposed to be case insensitive. Someone else above explained it very well:

"class_exists() function uses zend_str_tolower(). zend_str_tolower() uses zend_tolower(). zend_tolower() uses _tolower_l() on Windows and tolower() on other oses. _tolower_l() is not locale aware. tolower() is LC_CTYPE aware."

Edit: Someone else later said the following (I'm wondering if it's true):

"This, practically, can't be fixed. Mainly because there's no way to know if 'I' is uppercase of 'i' or 'ı' since there's not a separate place for Turkish 'I' in code tables. The same holds for 'i' (can't be known if it's lowercase of 'I' or 'İ'). I told 2 years ago and will say it again: PHP should provide a way to turn off case-insensitive function/class name lookup. No good programmer uses this Basic language feature since identifiers are case-sensitive in all real languages like Python, Ruby, C#, Java."

Re: PHP Bug #18556 : Setting locale to 'tr_TR' lowercases class names

#14
post #11

PHP is a big legacy open source project, worked on by many volunteers whenever they can spare the time, just like any other open source project. It is wildly successful despite this and many other bugs. I only wish that the people who spend as much time attacking PHP and it's developers endlessly would instead focus some of that energy into helping to improve PHP, but I guess some of us are just negatively charged. S…

[deleted]

Re: PHP Bug #18556 : Setting locale to 'tr_TR' lowercases class names

#16
post #11

PHP is a big legacy open source project, worked on by many volunteers whenever they can spare the time, just like any other open source project. It is wildly successful despite this and many other bugs. I only wish that the people who spend as much time attacking PHP and it's developers endlessly would instead focus some of that energy into helping to improve PHP, but I guess some of us are just negatively charged. S…

I think the people that attack it would rather see it die off than be "improved".

Re: PHP Bug #18556 : Setting locale to 'tr_TR' lowercases class names

#17
post #4

I is not capital of i in Turkish. Instead, İ is capital of i and I is capital of ı. They are two different letters.

No other language has this problem. The locale is irrelevant. The class name is just a series of bytes; it shouldn't need to transform the case.

Re: PHP Bug #18556 : Setting locale to 'tr_TR' lowercases class names

#18
post #15
post #4

I is not capital of i in Turkish. Instead, İ is capital of i and I is capital of ı. They are two different letters.

And this should affect class names why?

Apparently identifier lookup is done case-insensitively...

Re: PHP Bug #18556 : Setting locale to 'tr_TR' lowercases class names

#19
post #2

Words fail me.

I know it seems insane, but Turkish capitalization is not fun to work with as a programmer. When they latinized the alphabet 100 years ago or so, they were short on vowels and so it must have seemed pretty clever and convenient to make i and I separate letters with İ and ı respective case pairs. From a western programmers perspective though it's one of the worst unicode special cases owing to its combined unexpectedn…

Just my curiosity, how do you know that they were short on vowels?

Re: PHP Bug #18556 : Setting locale to 'tr_TR' lowercases class names

#20

I think this was a good explanation: "No, the problem results because lowercase i (in most languages) and uppercase I (in most languages) are not actually considered to be the upper/lower variant of the same letter in Turkish. In Turkish, the undotted ı is the lowercase of I, and the dotted İ is the uppercase of i. If you have a class named Image, it will break if the locale is changed to turkish because class_exists…

But, why should the locale change the way PHP code is interpreted? Shouldn't LC_ALL="C" when parsing the code?

Maybe it breaks if you embed unicode strings or something. What do other languages do?

Post reply on HN