-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSurrogate.java
More file actions
18 lines (17 loc) · 825 Bytes
/
Copy pathSurrogate.java
File metadata and controls
18 lines (17 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class Surrogate{
public static void main(String[] args){
char[] surrogatePair = {'\ud834', '\udd1e'}; // Pair of UTF-16 encoded characters.
// Note, if you want, that neither \uD834 nor \uDD1E are valid characters by themselves.
String s = new String(surrogatePair, 0, 2);
System.out.println(s);
// another way to do this.
// In Java, you can create Strings from the decimal representation of
// the Unicode code point.
// The treble clef is Unicode code point U+1D11E. Do not confuse this with the hex representation in UTF16
// the UTF 16 representation is the one above. The Unicode code point is the representation of the code point
// in ANY UTF-scheme.
int trebleClefInt = 0x1D11E;
String s2 = new String(new int[]{trebleClefInt, trebleClefInt}, 0, 2);
System.out.println(s2);
}
}