下面是我用非便攜式windows字符集解決問題的解決方案。這用它們的等價HTML實體替換了令人討厭的幾乎拉丁文-1字符。
$translation=array(
// reference from http://www.cs.tut.fi/~jkorpela/www/windows-chars.html
"\x82" => "‚",
"\x83" => "ƒ",
"\x84" => "„",
"\x85" => "…",
"\x86" => "†",
"\x87" => "‡",
"\x88" => "ˆ",
"\x89" => "‰",
"\x8a" => "Š",
"\x8b" => "‹",
"\x8c" => "Œ",
"\x91" => "‘",
"\x92" => "’",
"\x93" => "“",
"\x94" => "”",
"\x95" => "•",
"\x96" => "–",
"\x97" => "—",
"\x98" => "˜",
"\x99" => "™",
"\x9a" => "š",
"\x9b" => "›",
"\x9c" => "œ",
"\x9f" => "Ÿ",
);
return str_replace(array_keys($translation),array_values($translation),$input);
它爲我工作TM
根據我的經驗,即使所有正確的字符集編碼的,一些字符一下就被他們一到瀏覽器的時間吞噬。我不知道這是PHP中的一個錯誤(我使用的服務器語言最多)還是什麼,但我發現轉換爲更可靠的實體。 – eyelidlessness 2008-10-13 19:49:24