{"record":{"id":"e8725c02e3deb9ce","repo":"oven-sh/bun","slug":"ucd-parse-sanity-check-failed","errorCode":null,"errorMessage":"UCD parse sanity check failed","messagePattern":"UCD parse sanity check failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/generate-stringwidth-tables.mjs","lineNumber":120,"sourceCode":"  const high = cp >> 8;\n  const low = cp & 0xff;\n  return stage3[stage2[stage1[high] + low]] & 0x1f;\n};\n\nconst inRanges = (cp, ranges) => {\n  let lo = 0;\n  let hi = ranges.length;\n  while (lo < hi) {\n    const mid = (lo + hi) >> 1;\n    if (ranges[mid][0] <= cp) lo = mid + 1;\n    else hi = mid;\n  }\n  return lo > 0 && cp <= ranges[lo - 1][1];\n};\n\n// Guard against a UCD format change silently emptying a table.\nif (!inRanges(0x4e00, wideRanges) || !inRanges(0x300, nonspacingMarkRanges) || !inRanges(0x1f600, emojiRanges))\n  throw new Error(\"UCD parse sanity check failed\");\n\n// ---------------------------------------------------------------------------\n// Width classification\n// ---------------------------------------------------------------------------\n\n// Zero-width: controls, every nonspacing/enclosing mark (Mn/Me), conjoining\n// Hangul jungseong/jongseong, and the invisible format characters glibc\n// wcwidth() and string-width treat as zero-width. Deliberate deviations:\n// prepended concatenation marks (U+0600..) are zero-width, and the Indic\n// block heuristic below also zero-widths spacing vowel signs (Mc) so a\n// consonant+vowel-sign syllable stays one column.\nfunction isZeroWidth(cp) {\n  if (cp <= 0x1f) return true;\n  if (cp >= 0x7f && cp <= 0x9f) return true;\n  if (cp === 0xad) return true;\n  if (inRanges(cp, nonspacingMarkRanges)) return true;\n  // Hangul jungseong (V) and jongseong (T): an L+V(+T) conjoining cluster is\n  // 2 columns wide, all carried by the leading consonant.","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/scripts/generate-stringwidth-tables.mjs#L102-L138","documentation":"Error \"UCD parse sanity check failed\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at scripts/generate-stringwidth-tables.mjs:120 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}