20,359
社区成员
发帖
与我相关
我的任务
分享
if(! preg_match('/<meta[^>]+charset=/i', $html)) {
$charset = mb_check_encoding($html, 'utf-8') ? 'utf-8' : 'gbk';
$html = sprintf('<meta http-equiv="Content-Type" content="text/html; charset=%s">%s', $charset, $html);
}
再给 phpQuery 处理就没有问题了
当然,你也可以整体的转换成 utf-8 编码的