+ 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!

6th Apr 2021, 8:54 PM
Fu Foy
Fu Foy - avatar
7 Antworten
+ 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.
6th Apr 2021, 11:05 PM
Schindlabua
Schindlabua - avatar
+ 2
There should be a Content-Type header present. If that is missing then probably that's the issue right there!
7th Apr 2021, 10:21 AM
Schindlabua
Schindlabua - avatar
+ 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.
7th Apr 2021, 10:04 AM
Fu Foy
Fu Foy - avatar
+ 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.
7th Apr 2021, 10:57 AM
Schindlabua
Schindlabua - avatar
+ 1
Problem solved by simply using Volley in android-app. Works fine now. Thanks again!
7th Apr 2021, 1:09 PM
Fu Foy
Fu Foy - avatar
0
the content-type header: application/json
7th Apr 2021, 10:34 AM
Fu Foy
Fu Foy - avatar
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.
7th Apr 2021, 11:17 AM
Fu Foy
Fu Foy - avatar