title: Setting the charset of html response content to 1252
body: <p>I'm trying to send some data encoded in Windows 1252 (it's a CSV file) in an HTTP response, but somewhere along the way it's getting re-encoded to UTF-8 (no BOM). How can I make sure that the data stays in the correct encoding?</p>
  
  <pre><code>var sb = new StringBuilder();
  // Build the file from windows-1252 strings in the sb...
  HttpContext.Current.Response.Clear();
  HttpContext.Current.Response.ClearHeaders();
  HttpContext.Current.Response.ClearContent();
  HttpContext.Current.Response.AddHeader("content-disposition", string.Format("filename=\"{0}\".csv", fileName));
  HttpContext.Current.Response.ContentType = "text/csv;charset=windows-1252";
  HttpContext.Current.Response.Charset = "windows-1252";
  HttpContext.Current.Response.Write(sb.ToString());
  HttpContext.Current.Response.Flush();
  HttpContext.Current.Response.End();
  </code></pre>