title: How to GetBytes() in C# with UTF8 encoding with BOM?
body: <p>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 array with the following line:</p>
  
  <p><code>var x = Encoding.UTF8.GetBytes(csvString);</code></p>
  
  <p>but when I return it for download using: </p>
  
  <p><code>return File(x, ..., ...);</code></p>
  
  <p>I get a file which is without BOM so I don't get Croatian characters shown up correctly. This is because my bytes array does not include BOM after encoding. I triend inserting those bytes manually and then it shows up correctly, but that's not the best way to do it.</p>
  
  <p>I also tried creating UTF8Encoding class instance and passing a boolean value (true) to its constructor to include BOM, but it doesn't work either.</p>
  
  <p>Anyone has a solution? Thanks!</p>