There is a exe file native2ascii.exe in jdk’s bin that can convert Chinese to unicode.
It can be used in cmd window.
native2ascii [options] [inputfile [outputfile]]
- Perform the reverse operation: Convert a file encoded in ISO-8859-1 with Unicode escapes to a file in any character encoding supported by the Java runtime environment.
- Specifies the name of the character encoding to be used by the conversion procedure. If this option is not present, the default character encoding (as determined by the
java.nio.charset.Charset.defaultCharsetmethod) is used. The
encoding_namestring must be the name of a character encoding that is supported by the Java runtime environment – see the Supported Encodings document.
- 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 the startup memory to 48 megabytes.
- create a file and input Chinese, save as d:\a.txt in UTF-8 format.
- use native2ascii.exe to convert:
c:\Java\jdk1.6.0\bin>native2ascii.exe -encoding utf8 d:\a.txt d:\b.txt
the converted file is b.txt, open it
eg. result: \ufeff\u56fd\u6c11\u515a
- use the ext to convert back:
c:\Java\jdk1.6.0\bin>native2ascii.exe -reverse d:\b.txt d:\c.txt
the result was input to c.txt.
eg. result: \ufeff国民党
- the commond will add \ufeff as prefix. it can be removed using replaceAll: