【发布时间】:2018-12-21 21:09:37
【问题描述】:
我是 NodeJS 和 JS 的新用户。我正在使用 NodeJS 来制作我的 Web API 项目。我的项目使用 opensubtitles API。 Opensubtitles api 给我一个 .*gz 文件 URL。我想保存到此 URL 上的本地文件夹文件。我尝试了几种方法。但我没有成功。我在本地文件夹中下载了文件,但某些语言字符出现损坏。
示例文件网址:
https://dl.opensubtitles.org/en/download/src-api/vrf-19ed0c61/filead/1954767944.gz
如果我用网络浏览器下载它,字符会正常显示。
我的示例代码:
const out = fs.createWriteStream('out.srt');
request(subtitle.getSubDownloadLink()).pipe(zlib.createGunzip()).pipe(out);
【问题讨论】:
-
你知道文件的正确数据编码吗?
-
有几种不同的类型。示例:utf8 或 cp1254...此示例字幕文件语言为土耳其语。
标签: node.js file download character-encoding subtitle