{"record":{"id":"845e62e89ddaa253","repo":"nodejs/node","slug":"cannot-do-u8-n","errorCode":null,"errorMessage":"Cannot do u8'...'\\n","messagePattern":"Cannot do u8'\\.\\.\\.'\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/escapesrc/escapesrc.cpp","lineNumber":233,"sourceCode":"\n  pos++; // past 'u'\n\n  bool utf8 = false;\n  \n  if(linestr[pos] == '8') { // u8\"\n    utf8 = true;\n    pos++;\n  }\n  \n  char quote = linestr[pos];\n\n  if(quote != '\\'' && quote != '\\\"') {\n    fprintf(stderr, \"Quote is '%c' - not sure what to do.\\n\", quote);\n    return true;\n  }\n\n  if(quote == '\\'' && utf8) {\n    fprintf(stderr, \"Cannot do u8'...'\\n\");\n    return true;\n  }\n\n  pos ++;\n\n  //printf(\"u%c…%c\\n\", quote, quote);\n\n  for(; pos < linestr.size(); pos++) {\n    if(linestr[pos] == quote) {\n      if(utf8) {\n        return fixu8(linestr, origpos, pos); // fix u8\"...\"\n      } else {\n        return false; // end of quote\n      }\n    }\n    if(linestr[pos] == '\\\\') {\n      pos++;\n      if(linestr[pos] == quote) continue; // quoted quote","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/escapesrc/escapesrc.cpp#L215-L251","documentation":"escapesrc explicitly rejects the u8'x' form (UTF-8 narrow character literal). It supports u8\"...\" strings but not the single-character u8'...' literal, which the comment at fixAt documents as unsupported. The tool returns an error rather than emit incorrect output.","triggerScenarios":"A source line contains a u8-prefixed single-quoted character literal, e.g. u8'A' or u8'\\n'. fixAt detects (quote == '\\'' && utf8) and fails the line.","commonSituations":"Modern C++17+ code using u8 char literals; porting code that previously used char literals to UTF-8 literals for consistency; code generated by a tool that emits u8'...' uniformly.","solutions":["Rewrite u8'x' literals as plain 'x' (char) or as a u8\"x\" single-character string, which escapesrc does support.","If a multi-byte UTF-8 character is required, use u8\"\\uXXXX\" string form instead of a char literal.","Pre-process or post-process the source to convert u8'...' forms before running escapesrc."],"exampleFix":"// before\nchar c = u8'A';\n\n// after\nchar c = 'A';\n// or, if a UTF-8 string is intended:\nconst char* c = u8\"A\";","handlingStrategy":"validation","validationCode":"// pre-scan: rewrite u8'x' forms to supported forms before escapesrc\nimport re\nsrc2 = re.sub(r\"u8'(.)'\", lambda m: f\"u8\\\"{m.group(1)}\\\"\" if ord(m.group(1)) > 127 else f\"'{m.group(1)}'\", src)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ban u8'...' char literals in files processed by escapesrc via a coding-standard lint rule.","Prefer plain char or u8\"...\" string forms for portability across ICU's EBCDIC targets."],"tags":["icu","escapesrc","string-literal","utf-8","unsupported"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}