isZeroWidthCodePoint function
Returns true if the given code point occupies 0 terminal cells.
Implementation
bool isZeroWidthCodePoint(int codePoint) {
if (codePoint == 0) return true;
// C0 and C1 control characters (except tab/newline/carriage return)
if ((codePoint >= 0x01 && codePoint <= 0x1F) ||
(codePoint >= 0x7F && codePoint <= 0x9F)) {
return true;
}
// Soft Hyphen
if (codePoint == 0x00AD) return true;
// Combining Diacritical Marks
if (codePoint >= 0x0300 && codePoint <= 0x036F) return true;
if (codePoint >= 0x0483 && codePoint <= 0x0489) {
return true; // Cyrillic combining
}
if (codePoint >= 0x0591 && codePoint <= 0x05BD) {
return true; // Hebrew combining
}
// Hangul Jamo medial vowels & trailing consonants when isolated
if (codePoint >= 0x1160 && codePoint <= 0x11FF) return true;
// General Punctuation format controls: ZWSP, ZWNJ, ZWJ, LTR, RTL, etc.
if (codePoint >= 0x200B && codePoint <= 0x200F) return true;
// BiDi controls (LRE, RLE, PDF, LRO, RLO, etc.)
if (codePoint >= 0x202A && codePoint <= 0x202E) return true;
// Word joiner & Invisible operators
if (codePoint >= 0x2060 && codePoint <= 0x206F) return true;
// Standalone Variation Selectors 1..16
if (codePoint >= 0xFE00 && codePoint <= 0xFE0F) return true;
// Byte Order Mark / Zero Width No-Break Space
if (codePoint == 0xFEFF) return true;
// Interlinear annotation
if (codePoint >= 0xFFF9 && codePoint <= 0xFFFB) return true;
// Tags (Plane 14 language tag characters)
if (codePoint >= 0xE0000 && codePoint <= 0xE007F) return true;
return false;
}