A usage of the NATIVE2ASCII command

Source: Internet
Author: User

A usage of the NATIVE2ASCII command!

This command is described in the JDK file:

Native2ascii Convert text to Unicode Latin-1.

The syntax is as follows:

native2ascii [Options] [Inputfile [OutputFile]]

The specific options are:

-reverse

Perform the reverse Operation:convert a file with Latin-1 and/or

Unicode encoded characters to one with native-encoded characters.

-encoding Encoding_name

Specify the encoding name which is used by the conversion procedure.

The default encoding is taken from System property file.encoding. The

Encoding_name string must is taken from the the table of

Supported encodings in the supported encodings document.

-joption

Pass option to the Java virtual machine, where option is one of the

Options described on the reference page for the Java Application Launcher.

For example,-j-xms48m sets "startup memory to" megabytes

Sometimes when we decompile someone else's code, we see a code sentence like this,

System.out.println ("Connectionpool--\u521d\u59cb\u5316\u6570\u636e\u5e93\u5

F02\u5e38==>> "+ exception.tostring ());

Of course, this is just a simple sentence to print the error message, we can use the NATIVE2ASCII command to convert it into the original Chinese.

The procedure is as follows: If there is a document named: Test.class. First decompile it with the decompile tool, I'm using the DJ Java Jecompiler, the reverse-compiled file name extension is: ". Jad"

Import Java.io.PrintStream;
public class Test
{public
    static void main (String args[])
    {
        string s = 
"\u770b\u770b\u6211\u6d4b\ U8bd5\u7684\u6548\u679c\uff01 ";
        System.out.println (New 
StringBuilder ()). Append ("\u5475\u5475\uff1a"). Append (s). ToString ());

This is the decompile file.

There will be a corresponding file generation after the decompile. It is possible that the extension will not be directly ". Java", and it is okay to change the decompile file extension directly to. Java, as I have here, instead of Test.java. Then open dos, and then go to the appropriate directory: as follows:

J:\>

J:\>dir

2004-11-11 10:10 588 Test.jad

J:\>

Rename the Test.jad to Test.java, and then use the following command:

J:\>native2ascii-reverse-encoding gb2312 Test.java Test_gb2312.java

In combination with several options for this command, here are two options:

-reverse and-encoding,-encoding are followed by the specified encoding to be converted. I want to display it as Chinese, so I chose the Gb2312,test.java is the file renamed after the conversion, Test_gb2312.java is the code after the transcoding, with the EditPlus open look test_ Gb2312.java file, you will find Chinese display, this transcoding success, this command you have used it?

Oh, in the command line can also be real-time transcoding, open dos input native2ascii command, enter, and then there will be a cursor in the flash, do not think that the program did not finish, the cursor Flash is waiting for you to enter the characters, switch to the Chinese input state, input, "Java I love You" after the return, you will see this display: " Java\u6211\u7231\u4f60 "

Oh, is not very interesting. ^_^ ~ _~ ...... Today you harvest how much, knowledge by accumulation, friends, come on, one day, our knowledge will be like the pyramid.

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.