windows phone 8 - Encoding string issue reading a CSV file in C# -


i developing windows phone 8 application in 1 have download csv file web-service , convert data c# business object (i not use library part).

download file , convert data c# business object not issue using restsharp.portable, streamreader class , memorystream class.

the issue face bad encoding of string fields.

with library restsharp.portable, retrieve csv file content byte array , convert data string following code (where response byte array) :

using (var streamreader = new streamreader(new memorystream(response))) {   while (streamreader.peek() >= 0)   {     var csvline = streamreader.readline();   } } 

but instead of "jérome", csvline variable contains j�rome. tried several things obtain jérome without success :

using (var streamreader = new streamreader(new memorystream(response), true)) 

or

using (var streamreader = new streamreader(new memorystream(response), encoding.utf8)) 

when open csv file simple notepad software notepad++ obtain jérome when file encoding in ansi. if try following code in c# :

using (var streamreader = new streamreader(new memorystream(response), encoding.getencoding("ansi"))) 

i have following exception :

'ansi' not supported encoding name.

can me decode correctly csv file ?

thank in advance or advices !

you need pick 1 of these.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx

if don't know, can try guess it. guessing isn't perfect solution, per answer here.

you can't detect codepage, need told it. can analyse bytes , guess it, can give bizarre (sometimes amusing) results.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -