Page 58 - CA_Blue( J )_Class9
P. 58

8          {
                     9              char unicode = (char)i;

                    10              System.out.println(i+"\t\t"+unicode);
                    11          }

                    12      }
                    13  }


                  4.2.3 Difference between ASCII Code and Unicode

                                      ASCII Code                                          Unicode
                   ASCII stands  for American Standard Code for  Unicode stands for Universal Character Encoding.
                   Information Interchange.
                   The standard ASCII character  set only supports  128  Unicode  supports  a wide range of  characters, with
                   characters (character  range whose numeric value  more than 1.1 million characters currently defined.
                   is between 0 and 127). Extended ASCII supports 256
                   characters (character range 0-255).
                   ASCII only uses 1 byte to represent each character.  Unicode uses variable encoding  forms:  UTF-8 (1–4
                                                                     bytes), UTF-16 (2–4 bytes), and  UTF-32  (4 bytes) to
                                                                     represent characters.
                   ASCII code requires less space.                   Unicode requires more space.


                       4.3 ESCAPE SEQUENCES
                  A non-graphical character that is preceded by a backslash (\) and has a special meaning for the compiler is known
                  as Escape Sequence. Java has total eight escape sequences. They are used to perform a specific task and are valid
                  Character literals. For example, if we want to print a sentence with double quotes around a specific text, the
                  escape sequence \" is necessary to include those quotes in the output. To print the sentence: He said, “Hi! I am
                  there”. We should write:
                  System.out.println("He said, \"Hi! I am there\".");
                  Some commonly used Escape sequence are:

                                          Escape Sequence               Description
                                                 \t         Used to insert a tab.

                                                 \b         Used to insert a backspace.
                                                 \n         Used to insert a newline.

                                                 \r         Used to insert a carriage return.
                                                 \f         Used to insert a form feed.

                                                 \'         Used to insert a single quote character.
                                                 \"         Used to insert a double quote character.
                                                 \\         Used to insert a backslash character.







                    56    Touchpad Computer Applications-IX
   53   54   55   56   57   58   59   60   61   62   63