尝试用php显示越南字符

hgb9j2n6  于 2023-04-28  发布在  PHP
关注(0)|答案(3)|浏览(129)

当我尝试使用以下代码显示越南语字符时:

<?php

$str = "Nghệ thuật cắm hoa vải";

//echo utf8_encode(html_entity_decode(($str)));
echo html_entity_decode($str);

//echo $str;

?>

我得到了Ngh?thu?t c?m hoa va?i结果。尝试了几种选择,但都没有成功。有什么想法吗

bqucvtff

bqucvtff1#

对我来说很好:http://codepad.org/uTmORRmz
您的浏览器是否支持Unicode?

2skhul33

2skhul332#

尝试测试:

$str = mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1');
$str = mb_convert_encoding($str, 'ISO-8859-1', 'UTF-8');
hlswsv35

hlswsv353#

PHP脚本是否使用UTF-8编码?如果是,则发送一个标头来指示:

header("Content-type: text/html; charset=utf-8");

或者,请执行以下操作:

echo mb_convert_encoding($string, "HTML-ENTITIES", "UTF-8");

相关问题