convert special characters to unicode

Viewed 52

Context:

Weird Character: â
Unicode: \u03C0
Expected Outcome/Special Character: π

I have a JSON file which has various Unicodes when I am parsing the JSON file in flutter I can see that the Unicodes are now parsed into Special Characters.

Here I am storing the parsed JSON in a list

final List list = obj.body; //body having unicode \u____
print(list);

Output: Special Character in the Flutter text widget.

But when I try to create a new JSON data using this list it stores the Special Characters as Special Characters and not as Unicode and therefore when I am parsing the new JSON in flutter I am getting weird characters instead of Special Characters.

final newJson = {
  "Data":{
    "newJson":list
  }
}
final jsonData = json.encode(newJson);
print(jsonData) //has all the special characters
final decJson = json.decode(jsonData)
print(decJson); //printing this prints weird character 
0 Answers
Related