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();

Comments are closed.