c# - Encode a string with accents and money symbols and returns a FileStreamReturn(MemoryStream) MVC -
i have code:
stringbuilder output = new stringbuilder(); output.appendline("saldo disposición: 23.15€"); [...] system.text.unicodeencoding en = new unicodeencoding(); byte[] bytearray = en.getbytes(output.tostring()); memorystream stream = new memorystream(bytearray); string filename = guid.newguid().tostring("n").toupper() + ".csv"; stream.flush(); stream.seek(0, seekorigin.begin); return new filestreamresult(stream, "application/vnd.ms-excel") { filedownloadname = filename};
when open document symbol "€" , accent in "disposión" don't appears. seems that:
saldo disposici�n: 23.15�
does tell me how this?
thank you!!
the following works me:
string filename = guid.newguid().tostring("n").toupper() + ".csv"; memorystream stream = new memorystream(); streamwriter output = new streamwriter(stream, encoding.utf8, 2 << 22); output.writeline("column1,column2"); output.writeline("value column one,\"saldo disposición: 23.15€\""); output.writeline("another row col 1,another row col 2"); output.flush(); stream.seek(0, seekorigin.begin); return new filestreamresult(stream, "application/octet-stream") { filedownloadname = filename };
seems encoding.
http://en.wikipedia.org/wiki/unicode http://en.wikipedia.org/wiki/utf-8
Comments
Post a Comment