如何使用PHP简单HTML DOM解析器解析中文字符?

时间:2021-11-07 09:01:43

I am trying to parse a chinese website using Simple HTML DOM (http://simplehtmldom.sourceforge.net) but facing problem where all the chinese characters parsed became unrecognized symbols.

我正在尝试使用简单的HTML DOM (http://simplehtmldom.sourceforge.net)解析一个中文网站,但遇到的问题是,解析的所有中文字符都变成了无法识别的符号。

Example: "星洲網" became "星洲網"

示例:“星洲網”变成了“æ˜ÿæ´²c¶²”

How to use Simple HTML DOM to parse UTF-8 character? or anything I did wrong in my coding?

如何使用简单的HTML DOM来解析UTF-8字符?或者我在编码中做错了什么?

Below is my PHP coding:

下面是我的PHP代码:

<?php
require_once ("simple_html_dom.php");

$html = file_get_html("http://www.sinchew-i.com");
print $html->plaintext;
?>

1 个解决方案

#1


0  

header('Content-Type: text/html; charset=utf-8');

Check this Handling unicode

检查这个处理unicode

#1


0  

header('Content-Type: text/html; charset=utf-8');

Check this Handling unicode

检查这个处理unicode