phputf-8characterturkish

Turkish character bug in mb_strtoupper function of PHP


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.


Solution

  • 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