How to make sure my created filedownload is UTF-8? (and not UTF-8 without BOM)

后端 未结 3 1369
悲&欢浪女
悲&欢浪女 2021-02-08 15:51

i\'ve made a download function to download messages to a CSV file (code is below). Now when i open it up in notepad or notepad++ i see this:

é NY ø ╬ ║► ░ ê ö

(

3条回答
  •  醉梦人生
    2021-02-08 16:21

    You might want to try using the UTF8Encoding class. The constructor has a parameter that determines if it should provide the BOM or not. You'll probably have to use the GetBytes-method and write the string as a series of bytes in the response, and not convert it back into a .net string object.

提交回复
热议问题