How to GetBytes() in C# with UTF8 encoding with BOM?

前端 未结 4 999
余生分开走
余生分开走 2020-11-27 16:06

I\'m having a problem with UTF8 encoding in my asp.net mvc 2 application in C#. I\'m trying let user download a simple text file from a string. I am trying to get bytes arra

4条回答
  •  一生所求
    2020-11-27 16:40

    UTF-8 does not require a BOM, because it is a sequence of 1-byte words. UTF-8 = UTF-8BE = UTF-8LE.

    In contrast, UTF-16 requires a BOM at the beginning of the stream to identify whether the remainder of the stream is UTF-16BE or UTF-16LE, because UTF-16 is a sequence of 2-byte words and the BOM identifies whether the bytes in the words are BE or LE.

    The problem does not lie with the Encoding.UTF8 class. The problem lies with whatever program you are using to view the files.

提交回复
热议问题