Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
660 views
in Technique[技术] by (71.8m points)

character encoding - Fix Turkish Charset Issue Html / PHP (iconv?)

i'm having troubles displaying turkish characters, they are appearing as the little question mark with the diamond in the background in html.

How can I use iconv to fix this? Since I think thats the best option right? Right now my page is utf-8 encoded.

I need to support characters like

? ? ?

aswell as be able to insert them into my db.

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

First I tried, utf8 encode-decode, failed, changed file format from ASCII to UTF-8, tried utf encode again, changed file format several times and failed.

Then i found out "iconv", tried and failed. Changed locale with "setlocale". Tried Turkish, English and other types, failed.

At last i wrote this function and I'm happy with the output :)

function transliterateTurkishChars($inputText) {
    $search  = array('?', '?', '?', '?', '?', '?', '?', '?', '?', '?', 'ü', 'ü');
    $replace = array('c', 'C', 'g', 'G', 'i', 'I', 'o', 'O', 's', 'S', 'u', 'U');
    $outputText=str_replace($search, $replace, $inputText);
    return $outputText;
}
$goodText=transliterateTurkishChars($badText);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...