var stringu = @"\u003cbr /\u003e\u003cbr /\u003eHello world";
Background here - I'm using HttpClient to request data, and am getting back a JSON string in UTF-8 (Content-Type: application/json; charset=utf-8 is the the header on the response).
To simulate the content conversion I wrote this code
var stringu = @"\u003cbr /\u003e\u003cbr /\u003eHello world";
var ubytes = Encoding.UTF8.GetBytes(stringu);
var asciibytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, ubytes);
var ascii = Encoding.UTF8.GetString(asciibytes);
Console.WriteLine(ascii);
Console.ReadKey();
This does not work however. I admit - I do not fully understand UTF-16/8 conversions (or even if I need to make it, considering I just output the returned bytes to a html file), so any help here is appreciated.
Hello world - is the output I want on the console – user466512 Jul 23 '13 at 06:02
in a console. It's not HTML. Also, that string could already be written. Your code just converts it to ASCII and then back to UTF-16 by casting it to a string. – Cole Tobin Jul 23 '13 at 06:06
will not work on the console. What I have from my response is a UTF-8 string as shown. Ideally, the response's charset should've been UTF-16, but this I cannot control. – user466512 Jul 23 '13 at 06:12