I have an Android Aplication that reads a file with SQL script to insert data into a SQLite DB. However I need to know the exatly encoding of this file, I have an EditText that reads information from SQLite, and if the encoding is not right, it'll be shown as invalid characters like "?" instead of characters like "ç, í, ã".
I have the following code:
FileInputStream fIn = new FileInputStream(myFile);
BufferedReader myReader = new BufferedReader(new InputStreamReader(fIn, "ISO-8859-1"));
String aDataRow;
while ((aDataRow = myReader.readLine()) != null) {
if(!aDataRow.isEmpty()){
String[] querys = aDataRow.split(";");
Collections.addAll(querysParaExecutar, querys);
}
}
myReader.close();
this works for "ISO-8859-1" encoding, and works for UTF-8 if I set to "UTF-8" as a charset. I need to programatically detect the charset encoding (UTF-8 or ISO-8859-1) and apply the correct one to my code. Is there a simple way to do that?
ł
can't be represented in ISO-8859-1. And for distinguishing different ISO-8859-X encodings, you need statistics of character distributions in different languages. – lenz