Reputation: 81
My question is rather explanation for the Turkish colleges who have troubles with our funny characters.
It is for sure PHP 5 has a bug by capitalizing and also therefore collating them.
echo mb_strtoupper('Turkish capitals for ğ, i, ı, ş in uppercase', 'UTF-8');
gives the result: "TURKISH CAPITALS FOR Ğ, I, I, Ş IN UPPERCASE".
But it is wrong. The correct output should be "TURKİSH CAPİTALS FOR Ğ, İ, I, Ş İN UPPERCASE"
The problem in our language we have "i" in capitals "İ" and "ı" in capitals "I".
I guess you see the problem.
Whom shall we report this bug in PHP, does anybody know? Please inform and if you write a subroutine to solve this problem temporarily, it will be appreciated. Thanks ahead.
Upvotes: 3
Views: 6084
Reputation: 26385
mb_strtoupper
is not locale aware. For handling these sorts of transformations you can use a Transliterator
which is, e.g.:
echo Transliterator::create("tr-Upper")
->transliterate('Turkish capitals for ğ, i, ı, ş in uppercase');
outputs:
TURKİSH CAPİTALS FOR Ğ, İ, I, Ş İN UPPERCASE
Upvotes: 11
Reputation: 1426
you can write your own function for do this:
function trkish_upper($str){
$find = array('i', 'ı'); //any turkish chars
$replace = array('İ','I');
$new = str_replace($find,$replace,$str);
return $new;
}
Upvotes: 0
Reputation: 553
Can you try this:
function pre_up($str){
$str = str_replace('i', 'İ', $str);
$str = str_replace('ı', 'I', $str);
return $str;
}
echo mb_strtoupper(pre_up('Turkish capitals for ğ, i, ı, ş in uppercase'), 'UTF-8');
I don't know Turkish, is it correct?
Output
TURKİSH CAPİTALS FOR Ğ, İ, I, Ş İN UPPERCASE
Upvotes: 7