isWideCodePoint function

bool isWideCodePoint(
  1. int codePoint
)

Checks if a single code point represents a wide character.

Implementation

bool isWideCodePoint(int codePoint) {
  // Lowest wide character in Unicode is Hangul Jamo (0x1100).
  // Everything below 0x1100 (ASCII, Latin Extended, Cyrillic, Greek, Hebrew, Arabic) is 1 cell.
  if (codePoint < 0x1100) return false;

  // CJK Unified Ideographs & Extension A (most frequent wide characters in i18n text)
  if (codePoint >= 0x4E00 && codePoint <= 0x9FFF) return true;
  if (codePoint >= 0x3400 && codePoint <= 0x4DBF) return true;

  // Hangul Syllables
  if (codePoint >= 0xAC00 && codePoint <= 0xD7AF) return true;

  // CJK Symbols and Punctuation, Hiragana, Katakana, Hangul Compatibility Jamo, etc.
  if (codePoint >= 0x3000 && codePoint <= 0x31FF) return true;

  // Emojis & Miscellaneous Symbols and Pictographs (SMP)
  if (codePoint >= 0x1F300 && codePoint <= 0x1F9FF) return true;
  if (codePoint >= 0x1FA00 && codePoint <= 0x1FAFF) return true;

  // Fullwidth Forms
  if (codePoint >= 0xFF01 && codePoint <= 0xFF60) return true;
  if (codePoint >= 0xFFE0 && codePoint <= 0xFFE6) return true;

  // Miscellaneous Technical with Emoji_Presentation=Yes (⌚..⌛, ⏩..⏳, ⏰, ⏱, ⏲, ⏸..⏺)
  if (codePoint == 0x231A || codePoint == 0x231B) return true;
  if (codePoint >= 0x23E9 && codePoint <= 0x23F3) return true;
  if (codePoint >= 0x23F8 && codePoint <= 0x23FA) return true;

  // Miscellaneous Symbols & Dingbats with Emoji_Presentation=Yes (⚡, ⚪, ⚫, ✅, ❌, etc.)
  if (codePoint == 0x2614 || codePoint == 0x2615) return true;
  if (codePoint >= 0x2648 && codePoint <= 0x2653) return true;
  if (codePoint == 0x267F || codePoint == 0x2693 || codePoint == 0x26A1) {
    return true;
  }
  if (codePoint == 0x26AA || codePoint == 0x26AB) return true;
  if (codePoint == 0x26BD || codePoint == 0x26BE) return true;
  if (codePoint == 0x26C4 || codePoint == 0x26C5 || codePoint == 0x26CE) {
    return true;
  }
  if (codePoint == 0x26D4 || codePoint == 0x26EA) return true;
  if (codePoint == 0x26F2 || codePoint == 0x26F3 || codePoint == 0x26F5) {
    return true;
  }
  if (codePoint == 0x26FA || codePoint == 0x26FD) return true;
  if (codePoint == 0x2705 || codePoint == 0x270A || codePoint == 0x270B) {
    return true;
  }
  if (codePoint == 0x2728 || codePoint == 0x274C || codePoint == 0x274E) {
    return true;
  }
  if (codePoint >= 0x2753 && codePoint <= 0x2755) return true;
  if (codePoint == 0x2757) return true;
  if (codePoint >= 0x2795 && codePoint <= 0x2797) return true;
  if (codePoint == 0x27B0 || codePoint == 0x27BF) return true;

  // Additional symbols with Emoji_Presentation=Yes (⭐ U+2B50, ⭕ U+2B55)
  if (codePoint == 0x2B50 || codePoint == 0x2B55) return true;

  // CJK Unified Ideographs Extension B-F
  if (codePoint >= 0x20000 && codePoint <= 0x2EBEF) return true;

  // CJK Compatibility Ideographs
  if (codePoint >= 0xF900 && codePoint <= 0xFAFF) return true;

  // Additional CJK/Emoji ranges:
  if (codePoint >= 0x1100 && codePoint <= 0x11FF) return true; // Hangul Jamo
  if (codePoint >= 0x2E80 && codePoint <= 0x2FFF) {
    return true; // CJK Radicals Supplement & Kangxi Radicals etc
  }
  if (codePoint >= 0x1F000 && codePoint <= 0x1F2FF) return true;

  return false;
}