[英]php and wrong output with UTF-8 encoding
I am using php in order to read a .txt file which contains any kind of characters. 我正在使用php来读取包含任何类型字符的.txt文件。 When I use the php function, utf8_decode() characters such as éàêô... are correctly recognized but chinese characters are displayed as ????.
当我使用php函数时,utf8_decode()字符(例如éàêô...)可以正确识别,但中文字符显示为????。 And when I don't use utf8_decode() the echo output of a chinese character is something like 北京å.
当我不使用utf8_decode()时,汉字的回声输出就像北京å。 What is stranged is that on the source code of the generated webpage the chinese characters are corectly displayed.
奇怪的是,在生成的网页的源代码中,核心地显示了汉字。
How can I do to have a correct output ? 如何获得正确的输出?
I use the fgets function to creat a variable $buffer to read into the .txt file and then : 我使用fgets函数创建一个变量$ buffer来读取.txt文件,然后:
$buffer = explode(" ", $buffer);
foreach($buffer as $word){
//$word=utf8_decode($word);
echo "$word \n";
}
Thank you very much 非常感谢你
看看mb_string的不同的功能- http://php.net/mb_string
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.