http - 使用 'wget' 获取的 HTML 文件被 'less' 报告为二进制

标签 http wget

如果我使用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/

相关文章:

javascript - 在等待 Promise 时切换 AngularJS View

C++ HTTP 客户端在 GET 请求后挂起 read() 调用

json - 获取 400 错误请求原因 :required from google cloud stoarge json api

java - 通过 RESTful Web 服务编辑对象

image - 从网站下载图像

php - wget 从自定义网站下载由 PHP 加载的所有图像

php - 保存动态 PHP 页面以供离线查看

python - 中断 urllib.read

linux - 无法在 Ubuntu 14.04 LTS 上通过 wget 建立 SSL 连接

将网页的工作本地副本下载为单个 html 文件