我无法正确地看到cjk字符。它似乎是错误的ISO-8859编码。我认为UTF-8的编码是合适的。有人知道怎么解决这个问题吗。
$ wget http://yjs.cd120.com/daoshi.html
$ grep 'selectid="99"' daoshi.html
Binary file daoshi.html matches
$ file daoshi.html
daoshi.html: HTML document text, ISO-8859 text, with very long lines, with CRLF line terminators发布于 2019-06-13 17:38:01
首先,您必须确定通过wget (或curl )获得的文件的实际编码。
发出命令:
grep 'Content-Type' daoshi.html将展出:
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />其中charset=gb2312意味着html文件是用简体中文(GB 2312)编码的。
然后,可以使用iconv命令将文件转换为新的UTF-8版本:
iconv -f gb2312 -t utf-8 daoshi.html >daoshi-utf8.html最后,根据您的需要,您可能希望调整文件开头的meta标记内容,以匹配新的编码,例如使用sed:
sed s/charset=gb2312/charset=utf-8/ daoshi-utf8.html >daoshi-utf8-final.html发布于 2019-06-13 17:04:00
https://www.w3.org/International/questions/qa-changing-encoding
摘要:
步骤1:将数据保存为UTF-8
步骤2:在页面中声明编码
<meta charset="utf-8"/>步骤3:确保您的服务器执行正确的操作。
https://stackoverflow.com/questions/56585203
复制相似问题