Home Java Character Methods lowSurrogate() Java Character lowSurrogate() Method Definition In Java, Character.lowSurrogate(codePoint) returns the low surrogate : the second of the two chars that encode a supplementary code point. For U+1F600 it returns '\uDE00'.
The low surrogate carries the lowest 10 bits of the code point, added to 0xDC00. Because subtracting 0x10000 does not change those bits, you can compute it as 0xDC00 + (codePoint & 0x3FF).
A static method of java.lang.Character (Java 7+): call it on the class, as in Character.lowSurrogate(...); you do not need a Character object. No import is needed, because java.lang is always available.
Syntax Pass a supplementary code point.
char a = Character.lowSurrogate(0x1F600); // '\uDE00'
char b = Character.lowSurrogate(0x10000); // '\uDC00'
char c = Character.lowSurrogate(0x10FFFF); // '\uDFFF'
// Character.lowSurrogate('A') // unspecified result, do not do this Call What it does Character.lowSurrogate(cp)Second char of the pair. (char) (0xDC00 + (cp & 0x3FF))The same calculation by hand. Character.toCodePoint(Character.highSurrogate(cp), Character.lowSurrogate(cp))Round trip back to cp.
One overload, lowSurrogate(int codePoint), added in Java 7. On Java 5 and 6, Character.toChars(cp)[1] gives the same char for supplementary code points.
Library declarations // java.lang.Character (since Java 7)
public static char lowSurrogate(int codePoint) Parameters Parameter Description codePoint (int)A supplementary code point.
Return Value Return Value Description charA low surrogate from 0xDC00 to 0xDFFF when the input is supplementary.
Compare with Similar Methods Related methods:
Java Examples 1. Low surrogates of code points 2. Consecutive emoji 3. Round trip Example 1 — Low Surrogates for Four Supplementary Code Points Print the low surrogate in hex for the edges of the range and two emoji.
public class CharacterLowSurrogateValues {
public static void main(String[] args) {
int[] cps = {0x10000, 0x1F600, 0x1F44D, 0x10FFFF};
for (int cp : cps) {
System.out.println("U+" + Integer.toHexString(cp) + " low=0x"
+ Integer.toHexString(Character.lowSurrogate(cp)));
}
}
} U+10000 low=0xdc00
U+1f600 low=0xde00
U+1f44d low=0xdc4d
U+10ffff low=0xdfff How It Works The range ends. U+10000 has all low bits clear and gives 0xDC00; U+10FFFF has all low bits set and gives 0xDFFF.The last 10 bits. 0x1F600 ends in the bits 0x200, so its low surrogate is 0xDC00 + 0x200 = 0xDE00; 0x1F44D ends in 0x04D, giving 0xDC4D.No glyphs printed. Converting each char with Integer.toHexString keeps the output to plain hex digits.Example 2 — Consecutive Code Points Share a High Surrogate Four emoji in a row differ only in their low surrogate.
public class CharacterLowSurrogateRun {
public static void main(String[] args) {
for (int cp = 0x1F600; cp <= 0x1F603; cp++) {
System.out.println("0x" + Integer.toHexString(cp)
+ " -> 0x" + Integer.toHexString(Character.highSurrogate(cp))
+ " 0x" + Integer.toHexString(Character.lowSurrogate(cp)));
}
}
} 0x1f600 -> 0xd83d 0xde00
0x1f601 -> 0xd83d 0xde01
0x1f602 -> 0xd83d 0xde02
0x1f603 -> 0xd83d 0xde03 How It Works A loop over code points. cp runs from U+1F600 to U+1F603, four emoji faces in a row.Same first half. All four have the same upper bits, so highSurrogate stays at 0xD83D.The low half counts up. Adding 1 to the code point adds 1 to the low surrogate, from 0xDE00 to 0xDE03.Example 3 — Split into Surrogates and Join Back Again Check that toCodePoint(highSurrogate(cp), lowSurrogate(cp)) returns the original code point, and compare with the hand-written formula.
public class CharacterLowSurrogateRoundTrip {
public static void main(String[] args) {
int[] cps = {0x10000, 0x1D11E, 0x1F680, 0x10FFFF};
int ok = 0;
for (int cp : cps) {
char low = Character.lowSurrogate(cp);
boolean formula = low == (char) (0xDC00 + (cp & 0x3FF));
boolean back = Character.toCodePoint(Character.highSurrogate(cp), low) == cp;
if (formula && back) ok++;
}
System.out.println(ok + " of " + cps.length + " code points round-trip correctly");
}
} 4 of 4 code points round-trip correctly How It Works Masking the low bits. cp & 0x3FF keeps the lowest 10 bits; adding 0xDC00 gives the low surrogate, matching the method every time.Decoding again. toCodePoint combines the two halves back into one int, which equals the starting value.Edge cases included. The test covers the first and last supplementary code points as well as two in the middle.Frequently Asked Questions Which Java version added Character.lowSurrogate? Java 7. On older versions use Character.toChars(cp)[1] for supplementary code points.
How is the low surrogate calculated? It is 0xDC00 plus the lowest 10 bits of the code point: (char) (0xDC00 + (cp & 0x3FF)).
What if the code point is in the BMP? The result is unspecified. BMP code points are stored as a single char and have no surrogates.
Can lowSurrogate throw an exception? No. It never validates its argument, so check isSupplementaryCodePoint yourself.
How do I combine the two halves again? Character.toCodePoint(high, low), ideally after checking Character.isSurrogatePair(high, low).
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
13 people found this page helpful
Helpful Share Copy link Suggestion