开发者

How to correctly display UTF8 characters in Android?

开发者 https://www.devze.com 2023-01-14 19:21 出处:网络
I have a txt file in UTF8 format: æ β ç ð ə ħ ŋ ø θ œ χ n d ŋ b a t d s t b a t d t d t d t ẽ u e ë l n e e m n l e β e e e ĕ e é ē è ȅ

I have a txt file in UTF8 format:

æ β ç ð ə ħ ŋ ø θ œ χ n d ŋ b a t d s t b a t d t d t d t ẽ u e ë l n e e m n l e β e e e ĕ e é ē è ȅ

I need to show开发者_如何学JAVA it in Android, but some symbols do not display correctly.

How can I show all symbols correctly?


It all boils down that you need to read, treat and display it as UTF-8 all the way. For the reading part, you can use InputStreamReader to read an arbitrary InputStream using a specific encoding.

reader = new InputStreamReader(new FileInputStream("/file.txt"), "UTF-8");

For the treatment part, the Java language should do it transparently without any problems since it perfectly understands Unicode. For the displaying part, that depends on how/where exactly you're displaying it. At least, it should be configured to use UTF-8 for that.


I use UTF8. Its not help. I decide this q. I connect fonts(ttf) with transcription symbol, and all work correct.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号