Skip to content

Instantly share code, notes, and snippets.

@obfusk
Last active July 24, 2024 22:18
Show Gist options
  • Save obfusk/beeaeb1372ce5c447a5b5e6eee5f8201 to your computer and use it in GitHub Desktop.
Save obfusk/beeaeb1372ce5c447a5b5e6eee5f8201 to your computer and use it in GitHub Desktop.
$ java Unicode.java
55356
57331
65039
8205
9895
65039
---
127987
65039
8205
9895
65039
---
127987
65039
8205
9895
65039
public class Unicode {
public static void main(String[] args) {
String foo = "🏳️‍⚧️";
for (String x : foo.split("")) {
System.out.println(x.codePointAt(0));
}
System.out.println("---");
int n = foo.codePointCount(0, foo.length());
for (int i = 0; i < n; ++i) {
int j = foo.offsetByCodePoints(0, i);
System.out.println(foo.codePointAt(j));
}
System.out.println("---");
for (int c : foo.codePoints().toArray()) {
System.out.println(c);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment