Sending data in utf-8 format in REST service

I had a requirement from a client where data we were trying to send had some non-english characters i.e. Turkish characters.
Usually sending data by converting into bytes and send a stream works but client was unable to read.

Below are the two lines of code which worked for me

byte[] result = System.Text.Encoding.UTF8.GetBytes(Data);

byte[] buffer = Encoding.UTF8.GetPreamble().Concat(result).ToArray();

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>