I know this is old question but I am not satisfied with answers given before. My question is how to display french letters (like- é,à etc.) using UTF-8 or any technique.
Currently these are displaying "?".
My code is:
InputStream is = null;
try {
if(CommonUtilities.prefs.getString("KEY_LOCALE", "fr").equalsIgnoreCase("fr")){
is = getAssets().open("terms_txt_fr.txt");
}else{
is = getAssets().open("terms_txt_en.txt");
}
String term_tx =convertStreamToString(is);
String valueUTF8 = new String(term_tx.getBytes(), "UTF-8");
terms_tx.setText(valueUTF8);
} catch (IOException e) {
e.printStackTrace();
}
You code is fine, but you need to make sure, your input is UTF-8 encoded.
There are a lot of methods how to do it. Each of them is specific to your environment like your operating system. A good summary is given here: Best way to convert text files between character sets?
On Linux (I guess on OSX it's the same) you do:
iconv -f ISO-8859-15 -t UTF-8 in.txt > out.txt
Most good text editors have options for how to save files. You might want to check that too. In modern operating systems UTF-8 should be the default.