Java Unicode escape character small studies Author: Egg 2004/11/10 --------------------------------- ----------------------------------------- escape character all escape characters It is the second character of '/' heads 0-9: Octa U: is Unicode Transpins, the length is fixed to 6 bits: one B, T, N, F, R, ", / Not satisfied, it produces a compilation error.
Of course, provide octal and is also compatible with C language.
B, t, n, f, r is to control characters. The meaning is meant: describing the sender of the data stream hopes how those information is formatted or represented.
Unicode escape character is very interesting that it can be written in any location of the code, as long as the escape is legal. For example:
INT C = 0 / U003B The above code can be compiled, equivalent to int C = 0; / u003b is ';' Unicode code
The above example can't be convincing, so I specially write the following code to convert the string into the Unicode character. You can place the printed code in egghello.java, then run it, the result is excited of.
/ * * Author: Egg Date: 2004/11/10 String to Unicode * / Public Class ASC2UNICODE {Private StringBuffer CH;
PRIVATE STRINGBUFFER TCH;
ASC2UNICODE (STRINGBUFFER S) {CH = S; IF (ch.Length ()> 0) TCH = New StringBuffer (1000);
Void Transform () {if (ch.Length () <1) Return; for (int i = 0; i
StringBuffer getStr () {return tch;}
public static void main (String [] argv) {Asc2Unicode au = new Asc2Unicode (new StringBuffer (new String ( "public class EggHello {" "public static void main (String [] argv) {" "System.out.println (/ "Hello, World /"); " "} " "} ")))); au.transform (); system.out.println (au.getstr ());}}
Printing as follows: / u0070 / u0075 / u0062 / u006c / u0069 / u0063 / u0020 / u0063 / u006c / u0061 / u0073 / u0073 / u0067 / u0048 / u0065 / u006c / u006c / u006f / u007b / u0020 / U0020 / u0020 / u0070 / u0075 / u0062 / u006c / u0069 / u0063 / u0020 / u0073 / u0074 / u0061 / u0074 / u0069 / u0063 / u0069 / u0064 / u0020 / u006D / u0061 / u0069 / u006E / U0028 / u0053 / u0074 / u0072 / u0069 / u006E / u0067 / u005B / u005D / u0020 / u0061 / u0072 / u0067 / u0076 / u0079 / u0073 / u0074 / u0065 / u0075 / u002e / u006f / u0075 / U0074 / U002E / U0070 / U0072 / U0069 / U006E / U0074 / U006C / U006E / U0028 / U0022 / U006C / U006F / U002C / U0057 / U006F / U0072 / U006C / U0064 / U0022 / u0029 / u003b / U007D / u007d feels a bit like encrypted code! Of course, it is a shaping bell. . . However, it is still a more dizzy.
Unicode escape first studies here, drink some water, and play games. . .