开发者

How to get rid of the non-english letters on the string?

I want to get rid of the turkish characters with the english ones in the string and thats the function I wrote. However, in the server, its not recognized the letters. Any suggestions?

function strtolower_tr($string)
    {
        $low=array("Ü" => "U","ü" => "u", "Ö" => "O","ö" => "o", "Ğ" => "G","ğ" => "g", "Ş" => "S","ş" => "s", "Ç" => "C","ç" => "c", "İ" => "I","i" => "i", "I" => "i","I" => "I");
        return strtolower(strtr($string,$low));
    }

-------IN THE SERVER-------

$low=array("?~\" => "u?", "?~V" => "o?", "?~^" => "g", "?~^" => "s", "?~G" => "c", "İ" => "i", "I" => i");

EDITED:

I found this: However, its not working for letter 'ı' and 'I' setlocale(LC_ALL, 'en_US.UTF8'); function clearUTF($s) { $r = ''; $s1 = @iconv('UTF-8', 'ASCII//TRANSLIT', $s); $j = 0; for ($i = 0; $i < strlen($s1); $i++) { $ch1 = $s1[$i]; $ch2 = @mb_substr($s, $j++, 1, 'UTF-8'); 开发者_StackOverflow if (strstr('`^~\'"', $ch1) !== false) { if ($ch1 <> $ch2) { --$j; continue; } } $r .= ($ch1=='?') ? $ch2 : $ch1; } return $r; }


Is you file in utf encoding? You should use utf encoding for your source files, this will solve your problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜