0

I am posting JSON requests to an URL using Unity and C#. I am getting back responses in JSON format with texts containing some special characters. Such as: "ó", "ü","é" etc.

For the posting and receiving, I am using the WWW class of Unity. I have tried to convert the incoming byte[] the following way:

byte[] incomingBytes = Encoding.Convert(Encoding.UTF8, Encoding.Unicode, www.downloadHandler.data);
var str = Encoding.Unicode.GetString(incomingBytes);
Debug.Log(str);

It makes no effect on the output. I am still getting the following example text back: csap\u00e1sra instead of csapásra. Any idea how to get back a field containing special characters from a JSON in Unity/C#?

rjth
  • 95
  • 1
  • 3
  • 12
  • Seems like this is what you might be running into: http://stackoverflow.com/questions/11293994/how-to-convert-a-utf-8-string-into-unicode – Zimano Apr 18 '17 at 12:31
  • Isn't `\u00e1` UTF16 instead of UTF8? – redent84 Apr 18 '17 at 12:36
  • I've tried barnes53's answer with `DecodeFromUtf8` but no luck still. The weirdest part is if I take the printed text with the `\u` codes and manually add it to a string in my code it works. – rjth Apr 18 '17 at 14:14

0 Answers0