I'm writing a Danish dictionary app. I can index the source files correctly (I think--I use Lucene and DanishAnalyzer
), but I can't properly display the words in TextView
s and ListView
s. The letters æ
, ø
, and å
are displayed as question marks inside a diamond. How do I fix this?
Asked
Active
Viewed 1,414 times
2

Matthew Quiros
- 13,385
- 12
- 87
- 132
2 Answers
1
The problem is probably your data source and it's encoding. If you get the text from some web source you might have to encode it to UTF-8
and then put it in the TextView
.

Warpzit
- 27,966
- 19
- 103
- 155
-
My data source is an ordinary .txt file containing JSON. The Danish characters are displayed correctly when the text file is viewed from Eclipse (for some reason, it's not when viewed in Sublime Text 2). I wonder if it's possible to change the encoding of the `TextView` instead? I'm not using any special fonts in the app. – Matthew Quiros Dec 03 '12 at 08:01
-
What are you using for reading the data from the .txt file? My guess is that you could fix this by getting the data as bytes and making sure to convert decode them properly. – Warpzit Dec 03 '12 at 08:03
-
I use an InputStreamReader to read the file, pass on the huge, single JSON object to Google-GSON for parsing and conversion into a HashMap, then index the relevant String values in Lucene. – Matthew Quiros Dec 03 '12 at 08:15
-
@MattQuiros Maybe the inputstreamreader should be set to utf-8, here for similar problem: http://stackoverflow.com/a/4964652/969325 – Warpzit Dec 03 '12 at 08:45
0
I set the InputStreamReader
encoding to MacRoman
instead of UTF-8
. I supply this InputStreamReader
to GSON's fromJson()
method. I still don't understand what's going on though.

Matthew Quiros
- 13,385
- 12
- 87
- 132