I am trying to send UTF-16BE text file as a HTTP Response from ASP.NET app.
Response.ContentType = "text/plain";
Response.ContentEncoding = System.Text.UnicodeEncoding.BigEndianUnicode;
Response.WriteFile(filename);
but nothing shown as the result and Fiddler doesn't show any encoding
is it me or web browsers don't like utf-16 text ?
No, your web browser is not the problem.
This code:
context.Response.ContentType = "text/html";
context.Response.ContentEncoding = UnicodeEncoding.BigEndianUnicode;
context.Response.Write("Hello World");
Yields the expected content encoding:
But as soon as you use context.Response.WriteFile
, the content encoding gets removed. Not sure if this is a feature or not. I assume the software on the other end has to determine the content encoding based on the output returned.