c# - RestSharp ignores response charset encoding -
i'm using restsharp version 105.1.0 (.net 4.5.1) make rest call our own api. api sends responses following header of particular interest: content-type: application/json; charset=iso-8859-1
. can see, charset of response set iso-8859-1.
i expect response restsharp uses encoding decode response content. however, when @ restresponse.content
property, characters display �. far know means wrong encoding used. when try decoding rawbytes
manually using proper encoding, correct string.
i tried manually setting iso-8859-1 encoding
property on restclient
no avail.
how can make sure responses restsharp decoded using right encoding?
example code:
// setting encoding here not change result var client = new restclient(myapiuri) { encoding = encoding.getencoding("iso-8859-1") }; var request = new restrequest(method.get); var restresponse = client.execute(request); console.writeline(restresponse.content) // outputs content string wrong encoding // characters display �
thanks in advance!
i had problem, solve had byte array brings in irestresponse object , convert encode want
var request = new restrequest(method.get); var restresponse = client.execute(request); encoding encoding = encoding.getencoding("iso-8859-1"); var result = encoding.getstring(response.rawbytes); console.writeline(result);
Comments
Post a Comment