Invalid Arabic/Persian Word appears on the text in flutter

2,377

try the following, it is working for me with Arabic characters

return http.get(Uri.encodeFull(baseUrl), headers: {
      "Content-Type": "application/json",
    }).then((response) {
      return json.decode(utf8.decode(response.bodyBytes));
    });
Share:
2,377
Alok
Author by

Alok

A hands-on creative software developer with excellent communication, organizational skills. A hard-working person who believes in completing things, who has an experience in Object-Oriented Programming as well as working on different platforms. Great dedication with excellent focus on doing various task. A learning enthusiast who is comfortable with multiple tech languages & frameworks and would love to work in a very dynamic & aspirational environment.

Updated on December 10, 2022

Comments

  • Alok
    Alok over 1 year

    I'm trying to show the correct Arabic/Persian word coming from the api to my Text(). As far as it is english it is coming up fine, but as the language changes it returns something like LATIN1.

    Latin1 shows up for the arabic word

    I have followed this question to rectify my problem : Invalid Arabic characters With Utf-8 charset Retrived with http.get Flutter

    I have a string name coming from the API. It has a bar name as : Bar Beirut - بار بيروت. But in the response, I'm getting the above screenshot.

    What I have tried to first encode the string and then decode it, but it not working out.

    var encoded = utf8.encode(data['name']);
    this.name = utf8.decode(encoded);
    

    So I'm using this.name in my Text(), but it shows up english character and for arabic it shows up LATIN1. Any help would be appreciated. Thanks