[英]Why PHP won't convert special language characters, such as in Korean?
I have strings in different languages, such as Korean, encoded in UTF-8 (the strings). 我有用UTF-8编码的不同语言(例如韩语)的字符串(字符串)。
I am trying to convert them into something like &#number; 我正在尝试将它们转换为&#number; or ä
或ä etc. whenever possible, but using this in PHP:
等等,只要有可能,但是在PHP中使用它:
$str = htmlspecialchars($str, ENT_QUOTES);
doesn't do that. 不这样做。
What is the right way to do that? 什么是正确的方法?
You can use mb_convert_encoding
like this: 您可以像这样使用
mb_convert_encoding
:
mb_convert_encoding($str, "HTML-ENTITIES", "UTF-8");
As found here: Converting Korean characters into entities 如此处所示: 将韩文字符转换为实体
Here's the man page for reference: http://php.net/manual/en/function.mb-convert-encoding.php 这是参考手册页: http : //php.net/manual/zh/function.mb-convert-encoding.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.