During Java Development, some garbled characters may occur or files cannot be correctly identified or read because of inconsistent encoding methods. Native2ascii is a tool provided by Sun Java SDK. It is used to convert other text files (such as *. txt, *. ini, *. properties, *. Java, etc.) into unicode encoding.
1. Obtain native2ascii
Exactly.
Ii. Usage
Command line format:
Native2ascii.exe-[Options] [inputfile [outputfile]
Where:
-[Options] indicates the command switch. Two options are available:
-Reverse: uses Latin-1 or Unicode encoding to convert the local encoding format.
-Encoding encoding_name: encode the object to be converted.
Inputfile: The full name of the input file.
Outputfile: name of the output file. If this parameter is missing, it is output to the console.
The details are as follows:
1. Command Line Interaction
In this way, you can manually enter characters to implement interactive transcoding in real time on the console. Exit press Ctrl + c
1) Local encoding → Latin encoding:
Directly input native2ascii.exe,ProgramThe cursor will stop on the next line. You can directly input the characters you want to convert, for example:
D: \ jdk1.5.0 _ 06 \ bin> native2ascii.exe
We
\ U6211 \ u4eec
2) Latin-1 encoding → specify the encoding:
Directly tap native2ascii.exe-reverse, and the program cursor will stop on the next line. Then you can directly tap into the characters you want to convert, for example:
D: \ jdk1.5.0 _ 06 \ bin> native2ascii.exe-reverse
\ U6211 \ u4eec
We
2. file conversion method
In this way, you can specify inputfile and outputfile to implement transcoding.
1) specify encoding → Latin encoding:
For example:
D: \ jdk1.5.0 _ 06 \ bin> native2ascii.exe-encoding utf8 abc.txt bcd.txt
2) Latin-1 encoding → specify the encoding:
For example:
D: \ jdk1.5.0 _ 06 \ bin> native 2ascii.exe-reverse utf8 abc.txt bcd.txt
Note: Make sure that the region and language of the system are Chinese and Chinese.