How to avoid garbled code when reading and writing Chinese on Android

preface

The reason why Android reads the Chinese file is that the character format of the read file is inconsistent with that of the written file. Therefore, to avoid Chinese garbled code, write in a certain format when writing the file and read in a certain format when reading. In this way, there will be no garbled code. For other text reading, when you don't know what format, you can read the corresponding file information first and then transcode it accordingly.

The following is a class to avoid garbled code in Chinese reading and writing.

RWFile.java

Write a test demo project according to this class.

MainActivity.java

activy_ main.xml

Note: you need to add file read-write permission

summary

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. If you have any questions, you can leave a message. Thank you for your support for programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>