LearnToday
LearnToday

Reputation: 2902

Why is my flutter http response json decoding not returning foreign language characters

I am doing an http request with Flutter. The response body text for foreign language is broken. Here is the result for flutter: enter image description here

Of which it should be something like this: enter image description here

The language in question is Korean. Here is my http request code:

  fetchJobs() async {
   var response = await http.get(Global.apiurl + 'jobs/');
    if (response != null && response.statusCode == 200) {
      print(response.body);
      JobResultModel jsonResponse =
          JobResultModel.fromJson(jsonDecode(response.body));
      return jsonResponse.results;
    }
 }

Upvotes: 1

Views: 918

Answers (1)

user10539074
user10539074

Reputation:

try

import 'dart:convert';

end use

jsonDecode(utf8.decode(response.bodyBytes))

instead of

jsonDecode(response.body)

Upvotes: 4

Related Questions