Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string_decoder #51

Open
vivatoviva opened this issue Jun 10, 2019 · 0 comments
Open

string_decoder #51

vivatoviva opened this issue Jun 10, 2019 · 0 comments
Labels

Comments

@vivatoviva
Copy link
Owner

模块提供一个 API,用于以保留编码的多字节UTF-8UTF-16字符的方式将Buffer对象解码为字符串

文档部分

Buffer 实例写入 StringDecoder 实例时,将使用内部缓冲区来确保已解码的字符串不包含任何不完整的多字节字符。 它们保存在缓冲区中,直到下一次调用 stringDecoder.write() 或调用 stringDecoder.end() 为止。

  • StringDecoder类
    • new StringDecoder([encoding]):创建一个新的StringDector实例
    • end(Buffer):已字符串形式返回内部缓冲区的任何剩余输入,表示不完整的UTF-8或者UTF-16字符的字节将替换为适合字符编码的替换字符
    • write(buffer):返回一个已解码的字符串,确保在返回 的字符串中不包含Buffer、TypedArray、DataView末尾的任何不完整的多字节字符,并将其存储在内部缓冲器,以便下次调用stringDecoder.write()stringDecoder.end()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant