I'm trying to decode a zipped json file that is dropped (drag and drop file) into my Flutter web-app, however am having some challenges getting the correct text from the file.
For example, the file contains the following line: "Cond\u00c3\u00a9 Nast"
This should be Condé Nast. I am somewhat aware of character encoding, but this has me stumped.
This is currently how I'm unzipping, utf8 decoding and finally json decoding the file. I am using the Archive package to do the unzipping.
ArchiveFile theFile = otherFiles.first;
final fileString = Utf8Decoder().convert(theFile.content);
Iterable l = json.decode(fileString);
How would I go about printing the correct character from this input JSON file string? Is this an issue of incorrect encoding? Or Is it an issue with my implementation?
json.decodeis aStringwith"Cond\u00c3\u00a9 Nast", then I think it's likely that the JSON file was encoded incorrectly when it was written. Can you check the bytes oftheFile.content? The UTF-8 code units foréis the sequence 0xC3, 0xA9, so it seems like your string somehow was double-encoded to UTF-8.theFile.content. The correct sequence of UTF-8 bytes would be 0xC3, 0xA9. An incorrect sequence from double-encoding to UTF-8 would be 0xC3, 0x83, 0xC2, 0xA9.