javascript - 使用 NodeJS 将 .DEX 文件作为文本读取
问题描述
我目前正在编写一个脚本,该脚本将处理一些生成的 .dex 文件(来自另一个脚本)。当我使用时,fs.readFile(filename)
我在终端中将其作为返回:
<Buffer 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 24 6e 61 6d 65 09 ... 3011 more bytes>
但是,如果我在 VsCode 或记事本中打开文件,它是完全可读的文本。有没有办法解析这个终端对原始文本的响应,或者它是一个库?
提前致谢
解决方案
使用 utf-8 编码
with readFile如果未指定编码,则返回原始缓冲区。
const fs = require("fs");
async function main(){
const filePath = "./test.DEX";
const encoding = "utf-8";
const content = await fs.promises.readFile(filePath, encoding);
console.log(content);
}
main();
推荐阅读
- reactjs - 基于路由的代码拆分与 webpack 不起作用,未生成块
- c# - Try-Catch 块破坏代码
- reactjs - 如何使带有参数的 React Router 路由与另一条路由分开
- javascript - 从 javascript 到 php 的安全请求?
- oracle - 删除分区后,索引变得不可用,我该怎么办,
- azure - 如何使用 Blob 存储使 Azure 搜索按需运行
- html - 将 html 转换为 github 风格的 markdown
- java - 如何从 List<X509Certificate> 创建 SSLEngine
- swift - 如何从 firebase 获取图片下载链接
- c# - CryptographicOperations 在哪里?