有没有办法修复通过phpquery::newDocument运行这个html标记后显示不正确的字符?在使用 phpquery 创建新文档后,原始文档中的 -Classics with modern Woman- 周围有预定的双引号.
Is there a way to fix the characters that display improperly after running this html markup through phpquery::newDocument? There are slated double quotes around -Classics with modern Woman- in the original document that end up displaying improperly after creating the new doc with phpquery.
//Original document is UTF-8 encoded
$raw_html = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body><p>Mr. Smith of Bangkok celebrated the "Classics with modern Woman".</p></body></html>';
print($raw_html);
$aNew_document = phpQuery::newDocument($raw_html);
print($aNew_document);
原始输出:曼谷史密斯先生庆祝经典与现代女性".
Original Output: Mr. Smith of Bangkok celebrated the "Classics with modern Woman".
新文档输出:曼谷的史密斯先生与现代女性一起庆祝经典".
New Document Output: Mr. Smith of Bangkok celebrated the �Classics with modern Woman.
UTF-8 without BOM
编码保存页面.在脚本顶部添加此标题:
UTF-8 without BOM
encoding. Add this header on top of your script:
header("Content-Type: text/html; charset=UTF-8");
:如何在没有 BOM 的情况下将文件另存为 UTF-8 :
根据 OP 要求,您可以在 Windows 上执行以下操作:
On OP request, here's how you can do on Windows:
这篇关于使用 php 修复 html 文档上显示不正确的编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!