In Java, Character.isBmpCodePoint(codePoint) returns true when the code point is in the Basic Multilingual Plane (BMP): 0 to 0xFFFF. Those code points fit in a single char, so (char) codePoint is a safe conversion.
The BMP holds almost all characters in everyday use, including Latin, Greek, Cyrillic, Arabic, and the common CJK characters. Code points from 0x10000 upward (most emoji, historic scripts, rare CJK) need two chars instead.
A static method of java.lang.Character (Java 7+): call it on the class, as in Character.isBmpCodePoint(...); you do not need a Character object. No import is needed, because java.lang is always available.
Syntax
Pass an int code point.
Java
Character.isBmpCodePoint('A'); // true
Character.isBmpCodePoint(0xFFFF); // true, the last BMP code point
Character.isBmpCodePoint(0x1F600); // false, an emoji
Character.isBmpCodePoint(-1); // false
Call
What it does
if (Character.isBmpCodePoint(cp)) sb.append((char) cp);
Append a code point that fits in one char.
cp >>> 16 == 0
The same test, usable before Java 7.
Character.isBmpCodePoint(cp) ? 1 : 2
chars needed for a valid code point.
Only one overload, isBmpCodePoint(int codePoint), added in Java 7. On Java 6 write codePoint >>> 16 == 0, which is how the JDK implements it.
Library declarations
Java
// java.lang.Character (since Java 7)
public static boolean isBmpCodePoint(int codePoint)
Parameters
Parameter
Description
codePoint (int)
The code point to check.
Return Value
Return Value
Description
true
0 to 0xFFFF, including the surrogate range U+D800 to U+DFFF.