将 Buffer 转换为字符串Buffer 类提供了一个 .toString() 方法,可将 Buffer 转换为字符串。 TypeScript复制const buf = Buffer.from("hello"); const str = buf.toString(); // => "hello" 你可以选择指定编码和字节范围。 TypeScript复制const buf = Buffer.from("hello world!"); const str = buf.toString("utf8", 0, 5); // => "hello" 请参阅二进制数据。