, , . chatAt! codePointAt.
Similarly, you should not blindly use i++to iterate over a string. You should see if you can s.codePointAt(i) > Character.MAX_VALUEknow if you need to give an extra i++kicker.
For example, to print all code points in String sthe standard notation "U +":
private static void say_U_contents(String s) {
System.out.print("U+");
for (int i = 0; i < s.length(); i++) {
System.out.printf("%X", s.codePointAt(i));
if (s.codePointAt(i) > Character.MAX_VALUE) { i++; }
if (i+1 < s.length()) { System.out.printf("."); }
}
}
This way you can output both U+61.DF, U+3C3and U+1F4A9.1F4A9for the corresponding lines. This last one looks like "\uD83D\uDCA9\uD83D\uDCA9"that is just crazy.
source
share