nodejs/node · error
Illegal code point U+%X\n
Error message
Illegal code point U+%X\n
What it means
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.
Source
Thrown at deps/icu-small/source/tools/escapesrc/escapesrc.cpp:144
* @return true on failure
*/
bool appendUtf8(std::string &outstr,
const std::string &linestr,
size_t &pos,
size_t chars) {
char tmp[9];
for(size_t i=0;i<chars;i++) {
tmp[i] = linestr[++pos];
}
tmp[chars] = 0;
unsigned int c;
sscanf(tmp, "%X", &c);
UChar32 ch = c & 0x1FFFFF;
// now to append \\x%% etc
uint8_t bytesNeeded = U8_LENGTH(ch);
if(bytesNeeded == 0) {
fprintf(stderr, "Illegal code point U+%X\n", ch);
return true;
}
uint8_t bytes[4];
uint8_t *s = bytes;
size_t i = 0;
U8_APPEND_UNSAFE(s, i, ch);
for(size_t t = 0; t<i; t++) {
appendByte(outstr, s[t]);
}
return false;
}
/**
* Fixup u8"x"
* @param linestr string to mutate. Already escaped into \u format.
* @param origpos beginning, points to 'u8"'
* @param pos end, points to "
* @return false for no-problem, true for failure!View on GitHub (pinned to 1b2de5e052)
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.
Example fix
// before const char* s = u8"\U00120000"; // after const char* s = u8"\U0001F600";
Defensive patterns
Strategy: validation
Validate before calling
// scan source for wide escapes and reject out-of-range values before escapesrc runs
import re
for m in re.finditer(r'\\U([0-9A-Fa-f]{5,8})', src):
if int(m.group(1), 16) > 0x10FFFF:
raise ValueError(f'code point {m.group(0)} exceeds U+10FFFF') Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Cannot do u8'...'\n
- Illegal utf-8 sequence at Column: %d\n
- %s: usage: %s infile.cpp outfile.cpp
- Not a 'u'?
- Quote is '%c' - not sure what to do.\n
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/2685b922ccac3a36.
Report an issue: GitHub.