1
我有以下字符串:如何將Unicode特殊字符轉換爲html實體?
$string = "★ This is some text ★";
我想把它轉換爲HTML實體:
$string = "★ This is some text ★";
的解決方案大家都在寫:
htmlentities("★ This is some text ★", "UTF-8");
但ヶ輛不能將所有的unicodes轉換爲html實體。所以它只是給我的輸出與輸入相同的:
★ This is some text ★
我也試過這種解決方案既結合:
header('Content-Type: text/plain; charset=utf-8');
和:
mb_convert_encoding();
但是,這兩種打印和空結果,根本不轉換或錯誤地將星星轉換爲:
Â
如何將★和所有其他unicode字符轉換爲正確的html實體?
的http:// php.net/manual/en/function.htmlentities.php#107985 – iainn