containsCJK static method
Implementation
static bool containsCJK(String text) {
if (text.isEmpty) return false;
for (int i = 0; i < text.length; i++) {
int codePoint = text.codeUnitAt(i);
// Handle surrogate pairs for characters outside BMP
if (codePoint >= 0xD800 && codePoint <= 0xDBFF && i + 1 < text.length) {
int low = text.codeUnitAt(i + 1);
if (low >= 0xDC00 && low <= 0xDFFF) {
codePoint = 0x10000 + ((codePoint - 0xD800) << 10) + (low - 0xDC00);
i++; // Skip the low surrogate
}
}
if (isCJKCharacter(codePoint)) {
return true;
}
}
return false;
}