-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improper Text Encoding (UTF-8) #234
Comments
@frank06 I think the issue revolves back to |
Finally managed to solve the issue by modifying the Original Version...
// response handling
var contentType = 'application/json';
try {
if (response?.body.isNotEmpty ?? false) {
contentType = response!.headers['content-type'] ?? contentType;
final body = response.body;
if (contentType.contains('json')) {
responseBody = json.decode(body);
} else {
responseBody = response.body;
}
}
} on FormatException catch (e, stack) {
error = e;
stackTrace = stack;
}
... Modified Version...
// response handling
var contentType = 'application/json';
try {
if (response?.body.isNotEmpty ?? false) {
contentType = response!.headers['content-type'] ?? contentType;
if (contentType.contains('json')) {
responseBody = json.decode(utf8.decode(response.bodyBytes));
} else {
responseBody = response.body;
}
}
} on FormatException catch (e, stack) {
error = e;
stackTrace = stack;
}
... Hopefully it Helps Someone. But also take note that this for majorly |
Glad you found a workaround! I am hesitant to hardcode utf8 decoding so I'd need to analyze the situation. In tests, and probably if supplied by a backend, the header |
Hey, I had the same issue. I should have read the workaround earlier... spent 2 hours trying to fix the encoding. The JSON spec says that:
|
Thinking of changing |
Hello I have a REST Server returning JSON Responses using UTF-8 when I request the data through
flutter_data
I receive wrongly encoded text for example instead of gettingagakuŋŋaanye go n’agayita
as sent by the server, I getagakuÅÅaanye go nâagayita
. I am using the defualt headers;Really Need help here, everything works fine except this simple issue.
The text was updated successfully, but these errors were encountered: