I know it must be obvious but can’t find the answer.
What should I do to get the right characteres such as “, ‘, etc…?
This is the method I am using,
public void read(Context context) {
InputStream inputStream = context.getResources().openRawResource(
R.raw.puzzles);
Scanner scanner = new Scanner(inputStream);
scanner.useDelimiter(PATTERN);
for (int i = 0; i < 70; i++) {
ids[i] = scanner.next();
titles[i] = scanner.next();
questions[i] = scanner.next();
answers[i] = scanner.next();
}
}
Thanks
After a few days of research I finally found the answer.
First of all I created a BufferedReader from the InputStream for character reading instead of raw byte reading.
Most importantly I instantiated the InputStream with the constructor with the charSetName.
If you go to ‘Save as’ in your NotePad you can choose your Encoding.
Finally I found here the supported encodings.
The default one in NotePad seems to be ANSI, which doesn’t seem to be supported so I changed it and save my .txt file as UTF8.
Here is the code: