Unicode Values Of String In Java
Chapter:
String Handling
Last Updated:
05-08-2016 12:38:18 UTC
Program:
/* ............... START ............... */
public class JavaStringUnicodeValue {
public static void main(String[] args) {
String str = "Java Scan";
for (char c : str.toCharArray()) {
System.out.printf("\\u%04x \n", (int) c);
}
}
}
/* ............... END ............... */
Output
\u004a
\u0061
\u0076
\u0061
\u0020
\u0053
\u0063
\u0061
\u006e
Notes:
-
Unicode can be implemented by different character encodings. The most commonly used encodings are UTF-8, UTF-16 and the now-obsolete UCS-2. UTF-8 uses one byte for any ASCII character, all of which have the same code values in both UTF-8 and ASCII encoding, and up to four bytes for other characters.
Tags
Unicode Values Of String, String, Java