1

I tried a lot of things even tried changing the font of textview but could not get the expected result. Actually, I am just reading a .txt file from my raw folder and then displaying it in the textview. But I am facing a problem when characters like hyphen - and apostrophe ' appear. Not everywhere but the textview replaces those characters with ? symbol.

Attaching a screenshot of both, the file in notepad as well as textview.

Check this image

bad_coder
  • 11,289
  • 20
  • 44
  • 72
sagar vyas
  • 23
  • 3

3 Answers3

1

Got the solution to the problem Just converted the file encoding format from ANSI to UTF-8. other formats like big endian and unicode do not work.

sagar vyas
  • 23
  • 3
0

you can put your string in an array then compare "?" ASCII code with array cells. get your ASCII number in this link :

http://www.rapidtables.com/code/text/ascii-table.htm

0

Use this method to read the file as UTF-8 otherwise your file might be interrupted (open as ASCII and saved;) :

InputStream inputStream = ctx.getResources().openRawResource(resId);
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
Maher Abuthraa
  • 17,493
  • 11
  • 81
  • 103