{"record":{"id":"80f33f8cc29c305b","repo":"nodejs/node","slug":"error-in-preparsed-ucd-s-is-not-a-valid-unicod","errorCode":null,"errorMessage":"error in preparsed UCD: '%s' is not a valid Unicode string on line %ld\n","messagePattern":"error in preparsed UCD: '(.+?)' is not a valid Unicode string on line %ld\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/toolutil/ppucd.cpp","lineNumber":559,"sourceCode":"    }\n    start = static_cast<UChar32>(st);\n    end = static_cast<UChar32>(e);\n    return true;\n}\n\nvoid\nPreparsedUCD::parseString(const char *s, UnicodeString &uni, UErrorCode &errorCode) {\n    char16_t *buffer=toUCharPtr(uni.getBuffer(-1));\n    int32_t length=u_parseString(s, buffer, uni.getCapacity(), nullptr, &errorCode);\n    if(errorCode==U_BUFFER_OVERFLOW_ERROR) {\n        errorCode=U_ZERO_ERROR;\n        uni.releaseBuffer(0);\n        buffer=toUCharPtr(uni.getBuffer(length));\n        length=u_parseString(s, buffer, uni.getCapacity(), nullptr, &errorCode);\n    }\n    uni.releaseBuffer(length);\n    if(U_FAILURE(errorCode)) {\n        fprintf(stderr,\n                \"error in preparsed UCD: '%s' is not a valid Unicode string on line %ld\\n\",\n                s, static_cast<long>(lineNumber));\n    }\n}\n\nvoid\nPreparsedUCD::parseScriptExtensions(const char *s, UnicodeSet &scx, UErrorCode &errorCode) {\n    if(U_FAILURE(errorCode)) { return; }\n    scx.clear();\n    CharString scString;\n    for(;;) {\n        const char *scs;\n        const char *scLimit=strchr(s, ' ');\n        if(scLimit!=nullptr) {\n            scs = scString.clear().append(s, static_cast<int32_t>(scLimit - s), errorCode).data();\n            if(U_FAILURE(errorCode)) { return; }\n        } else {\n            scs=s;","sourceCodeStart":541,"sourceCodeEnd":577,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/toolutil/ppucd.cpp#L541-L577","documentation":"Thrown by PreparsedUCD::parseString() when u_parseString() fails to parse the input as a valid Unicode string after attempting both an initial parse and a buffer-overflow retry with an enlarged buffer. This function is used for multi-character string properties like Case_Folding, Lowercase_Mapping, Titlecase_Mapping, and Uppercase_Mapping. Note: this error does not set errorCode itself — it only reports the pre-existing U_FAILURE from u_parseString.","triggerScenarios":"A ppucd string property field contains malformed escape sequences or invalid UTF-like syntax. u_parseString expects a specific format (typically space-separated hex code units); any deviation causes failure. The error is triggered for fields like 'lc=', 'uc=', 'tc=', 'cf=' with invalid content.","commonSituations":"Missing or incorrect space separators between code units in string fields; using raw UTF-8 text instead of hex-encoded code units; truncated escape sequences; encoding issues in the ppucd file.","solutions":["Ensure string property values use the correct format: space-separated hexadecimal UTF-16 code units.","Verify there are no stray characters, missing spaces, or incomplete code unit pairs in the field.","Cross-reference with official Unicode case mapping data to verify the expected value format.","Check for BOM or encoding issues in the ppucd file that could corrupt string fields."],"exampleFix":"// before\n00DF;Lowercase_Mapping=00DF;...\n// after\n00DF;Lowercase_Mapping=00DF;...\n// For multi-char mappings, use space-separated units:\n// before: Case_Folding=00730073\n// after:  Case_Folding=0073 0073","handlingStrategy":"validation","validationCode":"// Pre-validate string property fields as space-separated hex code units\n#include <cstring>\n#include <cstdlib>\n\nbool isValidUnicodeStringField(const char* s) {\n    if (s == nullptr || *s == '\\0') return false; // empty may be valid for some properties\n    const char* p = s;\n    while (*p) {\n        // Skip leading spaces\n        while (*p == ' ') p++;\n        if (*p == '\\0') break;\n        // Parse hex code unit\n        char* end;\n        strtoul(p, &end, 16);\n        if (end == p) return false; // not a hex digit\n        p = end;\n    }\n    return true;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure string property values are space-separated hexadecimal UTF-16 code units.","Do not use raw UTF-8 text or other encodings in string property fields.","Validate string field formatting before building ICU data."],"tags":["icu","ucd","parse-error","build-tool","unicode-string"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}