Search code examples
androidcsvspecial-characterssimplecursoradapter

Special character in Android TextView stopped working in the app after almost a year?


7 months ago I built an app targeting Android 2.3.3 and above (API 10). In the app I use an SimpleCursorAdapter which is deprecated now. First the app reads a .csv document and saves the information in the SQLiteDatabase.

The SimpleCursorAdapter gets the info out of the database and shows a list on the screen. The .csv has a few words with the special character ë in it, example: variëteit. The app build 7 months ago that is now in the store works fine and shows the special character correct in the list.

Here is the problem:
When I build the app now on my phone it doesn't show the special character ë in the list but this instead:

enter image description here

When I download the 7 months old version from the store, it does show the correct special character.

The weird thing is, I didn't change the code! So I have no idea why it suddenly stopped working. Does anyone have an idea?

What did I try:
I tried to change the encoding to: ISO8859-1, but that also gave a weird character..

I tried: String correctText = Html.fromHtml(textView.getText().toString())); But that also didn't work.

EDIT: The problem is reading the .csv file. When I put the value in the database it is already incorrect. I tried reading the .csv file with different encodings, but I coulnd't get the right encoding... I tried all the standard encodings. But it still didn't work. I can't find out what the right encoding is...


Solution

  • When I checked the details of the file it told me it was UTF-8 encoded.

    I created an new file with Notepadd++, before I created that file I made sure Notepad++ had these settings: (Settings > Preferences... >)

    enter image description here

    I copied and pasted the content to this new file. Then it worked because the file was for sure good encoded in UTF-8.