isCjk function

bool isCjk(
  1. int codeUnit
)

Returns true if codeUnit belongs to a CJK script (Han, Hiragana, Katakana, Hangul).

Implementation

bool isCjk(int codeUnit) {
  // CJK Unified Ideographs + Extensions A/B
  if (codeUnit >= 0x4E00 && codeUnit <= 0x9FFF) return true;
  if (codeUnit >= 0x3400 && codeUnit <= 0x4DBF) return true;
  if (codeUnit >= 0x20000 && codeUnit <= 0x2A6DF) return true;
  // Hiragana
  if (codeUnit >= 0x3040 && codeUnit <= 0x309F) return true;
  // Katakana
  if (codeUnit >= 0x30A0 && codeUnit <= 0x30FF) return true;
  // Hangul Syllables
  if (codeUnit >= 0xAC00 && codeUnit <= 0xD7AF) return true;
  // CJK Compatibility Ideographs
  if (codeUnit >= 0xF900 && codeUnit <= 0xFAFF) return true;
  return false;
}