且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从无限字节流中读取 UTF-8 字符 - C#

更新时间:2023-11-25 10:13:22

而不是旨在转换完整缓冲区的 Encoding.UTF8.GetChars,获取 Decoder的实例> 并重复调用其成员方法 GetChars 这将利用 Decoder 的内部缓冲区来处理从一次调用结束到下一次调用的部分多字节序列.

Rather than Encoding.UTF8.GetChars which is designed to convert complete buffers, get an instance of Decoder and repeatedly call its member method GetChars this will make use of the Decoder's internal buffer to handle partial multi-byte sequences from the end of one call to the next.