Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decoding utf8 string in flutter

Im trying to display a string with emojis on a text widget. The string is encoded using utf8. My question is how can I decode the whole string so it will display to the text properly?

here is the string with emojis:

Testing emoticons post \ud83d\ude18\ud83d\udc4c\ud83e\udd70\ud83d\ude02\ud83e\udd73\u2708\ufe0f\ud83d\udc4a\ud83d\ude01\ud83d\ude01\ud83e\udd23\ud83d\ude04\ud83d\ude01\u2708\ufe0f\ud83d\ude01\ud83d\ude0d\ud83d\ude4f\ud83e\udd22\ud83d\ude2d

Currently I have this function :

String utf8convert(String text) {
   List<int> bytes = text.toString().codeUnits;
   return utf8.decode(bytes);
}
like image 367
kenjilaurel Avatar asked Sep 11 '26 21:09

kenjilaurel


1 Answers

If you are using API to get data with emojis.

final response =
      await _httpClient.get(uri);
jsonDecode(utf8.decode(response.bodyBytes))
like image 135
Sourav 12 Avatar answered Sep 13 '26 11:09

Sourav 12



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!