This section provides a tutorial example on how to \udddd Unicode code sequences back to a native encoding like UTF-8 with the 'native2ascii -encoding utf-8 -reverse' command.
"native2ascii" also offers the "-reverse" option to help you convert text files with any \udddd Unicode code
sequences back to any native encodings, like UTF-8, or GB2312.
The tutorial example below shows you how I converted some Chinese characters in a UTF-8 file to \udddd Unicode code sequences,
then back to a GB2312 encoded file:
C:\herong>type HelloUtf8.java
public class HelloUtf8 {
public static void main(String[] a) {
System.out.println("Hello world!");
System.out.println("世界你好!");
}
}
C:\herong>native2ascii -encoding utf-8
HelloUtf8.java HelloUtf8.unicode
C:\herong>type HelloUtf8.unicode
public class HelloUtf8 {
public static void main(String[] a) {
System.out.println("Hello world!");
System.out.println("\u4e16\u754c\u4f60\u597d\uff01");
}
}
C:\herong>native2ascii -encoding gb2312 -reverse
HelloUtf8.unicode HelloUtf8.gb2312
C:\herong>type HelloUtf8.gb2312
public class HelloUtf8 {
public static void main(String[] a) {
System.out.println("Hello world!");
System.out.println("-++t-p¦+úí");
}
}
As you can see, if you use "native2ascii" and "native2ascii -reverse" together,
you can convert any non-ASCII file from one encoding to another encoding.