{"record":{"id":"2685b922ccac3a36","repo":"nodejs/node","slug":"illegal-code-point-u-x-n","errorCode":null,"errorMessage":"Illegal code point U+%X\\n","messagePattern":"Illegal code point U\\+%X\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/escapesrc/escapesrc.cpp","lineNumber":144,"sourceCode":" * @return true on failure\n */\nbool appendUtf8(std::string &outstr,\n                const std::string &linestr,\n                size_t &pos,\n                size_t chars) {\n  char tmp[9];\n  for(size_t i=0;i<chars;i++) {\n    tmp[i] = linestr[++pos];\n  }\n  tmp[chars] = 0;\n  unsigned int c;\n  sscanf(tmp, \"%X\", &c);\n  UChar32 ch = c & 0x1FFFFF; \n\n  // now to append \\\\x%% etc\n  uint8_t bytesNeeded = U8_LENGTH(ch);\n  if(bytesNeeded == 0) {\n    fprintf(stderr, \"Illegal code point U+%X\\n\", ch);\n    return true;\n  }\n  uint8_t bytes[4];\n  uint8_t *s = bytes;\n  size_t i = 0;\n  U8_APPEND_UNSAFE(s, i, ch);\n  for(size_t t = 0; t<i; t++) {\n    appendByte(outstr, s[t]);\n  }\n  return false;\n}\n\n/**\n * Fixup u8\"x\"\n * @param linestr string to mutate. Already escaped into \\u format.\n * @param origpos beginning, points to 'u8\"'\n * @param pos end, points to \"\n * @return false for no-problem, true for failure!","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/escapesrc/escapesrc.cpp#L126-L162","documentation":"Emitted by parseHex() in escapesrc after it decodes a \\UXXXXXXXX escape and masks it to 21 bits (c & 0x1FFFFF). U8_LENGTH(ch) returns 0 only for code points beyond U+10FFFF, which cannot be encoded in UTF-8. The tool rejects such code points because it cannot emit a valid UTF-8 byte sequence for them.","triggerScenarios":"A source file contains a \\U escape whose hex value, after masking with 0x1FFFFF, is in the range 0x110000..0x1FFFFF (e.g. \\U00110000 or larger), or a truncated/malformed wide hex literal that sscanf reads as an oversized value.","commonSituations":"Hand-authored source with a typo in a \\UXXXXXXXX literal; generated code emitting out-of-range code points; copy-paste of an astral-plane literal with an extra digit.","solutions":["Find the offending \\U literal on the line reported by escapesrc and correct it to a value <= U+10FFFF.","If the literal was meant to be a narrower escape, use \\uXXXX (<= U+FFFF) or split into a surrogate pair.","Regenerate or re-export the source file so wide character literals stay within the valid Unicode range."],"exampleFix":"// before\nconst char* s = u8\"\\U00120000\";\n\n// after\nconst char* s = u8\"\\U0001F600\";","handlingStrategy":"validation","validationCode":"// scan source for wide escapes and reject out-of-range values before escapesrc runs\nimport re\nfor m in re.finditer(r'\\\\U([0-9A-Fa-f]{5,8})', src):\n    if int(m.group(1), 16) > 0x10FFFF:\n        raise ValueError(f'code point {m.group(0)} exceeds U+10FFFF')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lint source files for \\\\U escapes > U+10FFFF as a pre-commit check.","Generate wide literals from a single source-of-truth table that is range-checked."],"tags":["icu","escapesrc","unicode","utf-8","code-point"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}