+ 1
Django + REST + Android + German "Umlaut"
I have a rest-api for a django model and an android-app, to access the data. Everything works fine, but when I add the data to a textView in android, the german Umlaut (ÄäÜüÖö) is not rendered correctly. Ä -> ~A I think there is no problem with my api. I'm wondering, if the issue is caused by my android-app or could it be a problem with my database (postgresql). In java I have tried some stuff like charsets.UTF... or getBytes(), but it didn't work yet. Thanks for reading!
7 Réponses
+ 3
Moin!
I can't answer concretely as I have no experience with postgres or django or android. But yeah somewhere in the chain your data is not interpreted as utf-8.
I would try to run your api locally and query it with postman, a great tool for testing apis.
Does the HTTP response define utf-8 encoding? There should be a HTTP header present that looks like
Content-Type: application/json;charset=UTF-8
If the API response looks good and the encoding header is present, then it's some issue in the android code.
If the API response looks bad but the encoding header is present, then you might have read the data wrongly from your database. Like, you read utf8 data as ascii in your database code, and django turns the ascii back into utf-8. It could be because your database is misconfigured (wrong type of text field, not using utf-8 encoding..)
If the API response looks bad and the header is missing, try setting the character encoding to utf-8 manually, somewhere in your django code.
I hope this helps somewhat.
+ 2
There should be a Content-Type header present. If that is missing then probably that's the issue right there!
+ 1
Thanks for your reply. I've just tested Postman! Thanks! It's a great tool.
I've checked the header: Content-Language = de.
I've also checked my database-settings.
I will try to access the api with a windows-app and if that works without "Umlaut-Probleme", I'll check my android-app again.
EDIT: Windows-app is also not showing "Ä/Ü/Ö" correctly.
+ 1
idk should be fine hard to say. No charset but I think utf-8 is the default for json..
Does postman show the Umlauts correctly? If yes it's an android issue, if no it's a backend issue.
+ 1
Problem solved by simply using Volley in android-app. Works fine now. Thanks again!
0
the content-type header: application/json
0
In postman everything is displayed correctly. ("Regenbogen bähm" in this case :)).
EDIT: There must be a problem with my android app. I think I'm calling the rest-api in a wrong way.