phpQuery制作和其他人

时间:2011-09-08 12:13:57

标签: chars phpquery

当我有一个文件,我通过phpQuery运行时,其中包含 ©之类的内容。

所以当我有这个文件(hello.html)时:

hello, this is a test ©

我运行此代码:

$f = phpQuery::newDocumentFile( 'hello.html' );
echo $f->html();

我得到以下输出:

hello, this is a test ©

我有什么可以做的吗?

1 个答案:

答案 0 :(得分:1)

由于编码问题而出现,我会尝试使用utf8_encode将其从ISO-8859-1转换为UTF-8

$markup = file_get_contents('hello.html');
$utf8_markup = utf8_encode($markup);
$doc = phpQuery::newDocumentHTML($utf8_markup);

这是一篇相关的帖子HTML encoding issues - “” character showing up instead of “ ”

相关问题