c# - Bad Encoding when receiving response from HttpClient in UWP -


i making uwp(universal windows platform) application , want deserialize xml: http://radioa24.info/ramowka.php object, got instead scpecial characters ł, ó strange letters , special ones like: \n , \r: "Ä…"=>"ą" "ć"=>"ć" "Ä™"=>"ę" example instead of poniedziałek got poniedziaÅ\u0082ek

my code:

var httpclient = new httpclient(); var response = await httpclient.getasync(uri).astask(); response.ensuresuccessstatuscode(); var result = await httpresponse.content.readasstringasync(); 

i trying make encoding convertions nothing worked out. how solve because later want got object?

var reader = new xmlserializer(typeof(sources.schedule)); using (var tr = new memorystream(encoding.utf8.getbytes(resultstring))) {    schedule = (sources.schedule)reader.deserialize(res); } 

please can try code below, reading data bytes solves issue.

using (httpclient client = new httpclient()) {     uri url = new uri("http://radioa24.info/ramowka.php");     httprequestmessage httprequest = new httprequestmessage(httpmethod.get, url);     task<httpresponsemessage> responseasync = client.sendrequestasync(httprequest).astask();     responseasync.wait();     responseasync.result.ensuresuccessstatuscode();      task<ibuffer> asyncbuffer = responseasync.result.content.readasbufferasync().astask();     asyncbuffer.wait();     byte[] resultbytearray = asyncbuffer.result.toarray();     string responsestring = encoding.utf8.getstring(resultbytearray, 0, resultbytearray.length);      responseasync.result.dispose(); } 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -