{"record":{"id":"b9b4b4c2398bfba2","repo":"nodejs/node","slug":"errorcode","errorCode":"errorCode","errorMessage":"icupkg: swapInvChars(output package name) failed - %s\n","messagePattern":"icupkg: swapInvChars\\(output package name\\) failed - (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/toolutil/package.cpp","lineNumber":785,"sourceCode":"    }\n\n    // prepare and swap the package name with a tree separator\n    // for prepending to item names\n    if(pkgPrefix[0]==0) {\n        prefixLength = static_cast<int32_t>(strlen(prefix));\n    } else {\n        prefixLength = static_cast<int32_t>(strlen(pkgPrefix));\n        memcpy(prefix, pkgPrefix, prefixLength);\n        if(prefixEndsWithType) {\n            prefix[prefixLength-1]=outType;\n        }\n    }\n    prefix[prefixLength++]=U_TREE_ENTRY_SEP_CHAR;\n    prefix[prefixLength]=0;\n    if(dsLocalToOut!=nullptr) {\n        dsLocalToOut->swapInvChars(dsLocalToOut, prefix, prefixLength, prefix, &errorCode);\n        if(U_FAILURE(errorCode)) {\n            fprintf(stderr, \"icupkg: swapInvChars(output package name) failed - %s\\n\", u_errorName(errorCode));\n            exit(errorCode);\n        }\n\n        // swap and sort the item names (sorting needs to be done in the output charset)\n        dsLocalToOut->swapInvChars(dsLocalToOut, inStrings, inStringTop, inStrings, &errorCode);\n        if(U_FAILURE(errorCode)) {\n            fprintf(stderr, \"icupkg: swapInvChars(item names) failed - %s\\n\", u_errorName(errorCode));\n            exit(errorCode);\n        }\n        sortItems();\n    }\n\n    // create the output item names in sorted order, with the package name prepended to each\n    for(i=0; i<itemCount; ++i) {\n        length = static_cast<int32_t>(strlen(items[i].name));\n        name=allocString(false, length+prefixLength);\n        memcpy(name, prefix, prefixLength);\n        memcpy(name+prefixLength, items[i].name, length+1);","sourceCodeStart":767,"sourceCodeEnd":803,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/toolutil/package.cpp#L767-L803","documentation":"icupkg appends a U_TREE_ENTRY_SEP_CHAR to the package prefix and swaps those invariant characters to the output charset via swapInvChars. If the swap reports a failure, the tool exits with the propagated error code. This catches prefixes containing characters that are not invariant across the target charset.","triggerScenarios":"In writePackage, 'dsLocalToOut->swapInvChars(...prefix...) returns U_FAILURE(errorCode). Triggered when the package prefix contains bytes that are not valid invariant characters for the output charset family (e.g. non-ASCII in a prefix being swapped to EBCDIC).","commonSituations":"A package name with non-ASCII or unusual punctuation; an output charset family that does not cover the prefix's characters; a hand-set pkgPrefix from a non-canonical source.","solutions":["Ensure the package name/prefix uses only ICU invariant characters (printable ASCII alphanumerics, '.', '_').","Use the canonical package basename derived by extractPackageName rather than a custom prefix.","Switch the output type to one matching the source charset family to avoid the invariant-char swap."],"exampleFix":"# before - prefix with non-invariant chars\nicupkg -p \"my-pkg_v2\" -te out.dat\n\n# after - use ASCII-only canonical prefix\nicupkg -p \"mypkg\" -te out.dat","handlingStrategy":"validation","validationCode":"# Validate that the package prefix contains only ICU invariant characters\n# (ASCII letters, digits, '.', '_') before swapping.\ncase \"$PKG\" in\n  *[!A-Za-z0-9._]*) echo \"prefix '$PKG' has non-invariant chars\" >&2; exit 1 ;;\nesac\nicupkg -p \"$PKG\" -te out.dat","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only ASCII alphanumeric characters, '.', and '_' in package names.","Prefer the canonical basename produced by extractPackageName.","Avoid EBCDIC output unless the prefix is ASCII-invariant."],"tags":["icu","icupkg","data-package","endian-swap","charset","cli-tool"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}