Roberto Salvador
Roberto Salvador

Reputation: 9

Restsharp request with UTF-8 encoding

As far as I understood.... RestSharp serializer's output is always a String. String is defined by .Net as collection of characters using UTF-16. So there is no way to modify the encoding of the request, so I can change it, the header will be changed, the XML header will be UTF-8 for example, but the encoding of the request will be always a String so it will be UTF-16.

https://learn.microsoft.com/en-gb/dotnet/api/system.string?view=netframework-4.8

using System;namespace RestSharp.Serializers
{
    public interface ISerializer
    {
        string ContentType { get; set; }        
        string Serialize(object obj);
    }
}

Upvotes: 0

Views: 5986

Answers (1)

Roberto Salvador
Roberto Salvador

Reputation: 9

Solved: I found the solution. Client.Encoding property sets the encoding, checking the RestSharp code it used to set the bytes in the request.

Upvotes: 0

Related Questions