如果我使用wget
下载this页面:
wget http://www.aqr.com/ResearchDetails.htm -O page.html
然后尝试在 less
中查看该页面,less 报告该文件是二进制文件。
less page.html
"page.html" may be a binary file. See it anyway?
这些是响应 header :
Accept-Ranges:bytes
Cache-Control:private
Content-Encoding:gzip
Content-Length:8295
Content-Type:text/html
Cteonnt-Length:44064
Date:Sun, 25 Sep 2011 12:15:53 GMT
ETag:"c0859e4e785ecc1:6cd"
Last-Modified:Fri, 19 Aug 2011 14:00:09 GMT
Server:Microsoft-IIS/6.0
X-Powered-By:ASP.NET
在 vim 中打开文件工作正常。
有什么线索可以解释为什么 less 无法处理它吗?
最佳答案
这是一个 UTF-16 编码的文件。 (Check with W3C Validator)。您可以使用以下命令将其转换为 UTF-8:
wget http://www.aqr.com/ResearchDetails.htm -q -O - | iconv -f utf-16 -t utf-8 > page.html
less
通常都知道 UTF-8。
编辑:
正如 @Stephen C 报道的那样,Red Hat 中的 less
支持 UTF-16。在我看来Red Hat patched less for UTF-16 support 。关于official site of the less UTF-16 支持目前是一个悬而未决的问题(引用号 282)。
关于http - 使用 'wget' 获取的 HTML 文件被 'less' 报告为二进制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7545459/