Whats going on with this byte array?

后端 未结 1 1573
闹比i
闹比i 2021-02-07 23:31

I have a byte array: 00 01 00 00 00 12 81 00 00 01 00 C8 00 00 00 00 00 08 5C 9F 4F A5 09 45 D4 CE

It is read via StreamReader using UTF

1条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-08 00:20

    The original byte array is not encoded as UTF-8. The StreamReader therefore replaces each invalid byte with the replacement character U+FFFD. When that character gets encoded back to UTF-8, this results in the byte sequence EF BF BD. You cannot construct the original byte value from the string because the information is completely lost.

    0 讨论(0)
提交回复
热议问题