Can the Encoding API decode a Stream/noncontinuous bytes?

后端 未结 3 1723
[愿得一人]
[愿得一人] 2021-01-28 06:49

Usually we can get a string from a byte[] using something like

var result = Encoding.UTF8.GetString(bytes);

However,

3条回答
  •  故里飘歌
    2021-01-28 07:27

    however Encoding cannot work on Stream, just byte[].

    Correct but a StreamReader : TextReader can be linked to a Stream.

    So just create that MemoryStream, push bytes in on one end and use ReadLine() on the other. I must say I have never tried that.

提交回复
热议问题