Tool native2ascii.exe provided by JDK

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.