にテキストを書いていますTextWriter
。出力に UTF-16 バイト オーダー マーク ( BOM
) を表示したい:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentEncoding = new UnicodeEncoding(true, true);
WriteStuffToTextWriter(context.Response.Output);
}
出力にバイトオーダーマークが含まれていないことを除いて:
HTTP/1.1 200 OK
Server: ASP.NET Development Server/10.0.0.0
Date: Thu, 06 Sep 2012 21:09:23 GMT
X-AspNet-Version: 4.0.30319
Content-Disposition: attachment; filename="Transactions_Calendar_20120906.csv"
Cache-Control: private
Content-Type: text/csv; filename="Transactions_Calendar_20120906.csv"; charset=utf-16BE
Content-Length: 95022
Connection: Close
JobName,ShiftName,6////09////2012 12::::00::::00 АΜ,...
TextWriter
にエンコーディング マーカーを書き込むように指示するにはどうすればよいですか?
注: の2 番目UnicodeEncoding
のパラメーター:
context.Response.ContentEncoding = new UnicodeEncoding(true, true);
byteOrderMark
タイプ: Unicode バイト オーダー マークが提供されることを指定する場合はtrue 。それ以外の場合はfalse。System.Boolean