Quantcast
Channel: Flutter - Character encoding is not behaving as expected - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by dubace for Flutter - Character encoding is not behaving as expected

$
0
0

The problem is that your JSON is stored locally.

Let's say you have
Map<String, String> jsonObject = {"info": "ÆææÖöö"};

So to show your text correctly you have to encode and decode back your JSON with utf-8.

I understand that's serialization and deserialization are costly operations, but's it's a workaround for locally stored JSON objects that contains UTF-8 texts.

import 'dart:convert';jsonDecode(jsonEncode(jsonObject))["info"]

If you get that JSON from server, then it's much more simpler, for example in dio package you can chose contentType params that's is "application/json; charset=utf-8" by default.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images