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