Monday, August 22, 2011

Fun with Unicodes


Sorry for the noob share :) I learned that you can code a java program all using Unicode :) all you need to do is duplicate the unicode marker ( "\uu ") followed by the hex digits. ( I actually got this stuff while reading the java language specs) .

Here's a little program I wrote that will demonstrate how you can code in unicode.

public cla\uu0073\uu0073 UnicodeEscapes {

public static void main (String [] args) {
int \uu0053 = 5;
\uu0053ystem.out.println ("\u0053 " + " printing " + S) ;
}

}



Here is the output of the code :)

Here's the snippet of the book that explains how this functions :

"The Java programming language specifies a standard way of transforming a
program written in Unicode into ASCII that changes a program into a form that
can be processed by ASCII-based tools. The transformation involves converting
any Unicode escapes in the source text of the program to ASCII by adding an
extra u—for example, \uxxxx becomes \uuxxxx—while simultaneously converting
non-ASCII characters in the source text to Unicode escapes containing a single
u each."

Below is a link to a Unicode chart :)

be passionate on what you do and everything else will follow :)
happy coding.