Module 基礎模塊

模塊string_decoder

解碼 Buffer 到字符串

使用方法:

1 2 3 4 5 6 7 8 9 10
const { StringDecoder } = require('string_decoder'); const decoder = new StringDecoder('utf8'); const cent = Buffer.from([0xC2, 0xA2]); console.log(decoder.write(cent)); const euro = Buffer.from([0xE2, 0x82, 0xAC]); console.log(decoder.write(euro));

對象

StringDecoder

創建一個解碼對象,參見 StringDecoder

1
StringDecoder string_decoder.StringDecoder;