2012-09-23 108 views
1

我想編一個字符串到utf8編碼,但我不知道原始字符集是什麼。如何將字符串更改爲utf8編碼?

字符串的原始字符集可能是GBK,iso-8859-1或其他我不知道的字符串。

我用mb_detect_encoding($content, 'UTF-8', true)iconv($original, "UTF-8", $content);

如何獲得原始編碼?

+0

你讀過[了'mb_detect_encoding()'文檔】(http://php.net/manual/en/function.mb-detect-encoding.php)? 'mb_detect_encoding($ content,'UTF-8',true)'沒有任何意義。 – lanzz

+1

然後你嘗試'mb_detect_encoding($ content,'auto',true)'。需要警告的是,在任何情況下都沒有辦法正確檢測您的編碼,因爲它更像是一個猜測過程。 – HerrSerker

回答

相關問題