nodejs/node · warning

###WARNING: No converter defined. Using codepage of system.

Error message

###WARNING: No converter defined. Using codepage of system.

What it means

Emitted from ucbuf_open after BOM autodetection and an explicit ucnv_open(*cp) have both failed to produce a converter (buf->conv is still nullptr). With showWarning true it warns that conversion will fall back to the platform's default codepage; reading continues but byte interpretation is implicit and may be wrong.

Source

Thrown at deps/icu-small/source/tools/toolutil/ucbuf.cpp:499

        if(*cp==nullptr || **cp=='\0'){
            /* don't have code page name... try to autodetect */
            ucbuf_autodetect_fs(in,cp,&buf->conv,&buf->signatureLength,error);
        }else if(ucbuf_isCPKnown(*cp)){
            /* discard BOM */
            ucbuf_autodetect_fs(in,&knownCp,&buf->conv,&buf->signatureLength,error);
        }
        if(U_SUCCESS(*error) && buf->conv==nullptr) {
            buf->conv=ucnv_open(*cp,error);
        }
        if(U_FAILURE(*error)){
            ucnv_close(buf->conv);
            uprv_free(buf);
            T_FileStream_close(in);
            return nullptr;
        }
        
        if((buf->conv==nullptr) && (buf->showWarning==true)){
            fprintf(stderr,"###WARNING: No converter defined. Using codepage of system.\n");
        }
        buf->remaining=fileSize-buf->signatureLength;
        if(buf->isBuffered){
            buf->bufCapacity=MAX_U_BUF;
        }else{
            buf->bufCapacity=buf->remaining+buf->signatureLength+1/*for terminating nul*/;               
        }
        buf->buffer=(char16_t*) uprv_malloc(U_SIZEOF_UCHAR * buf->bufCapacity );
        if (buf->buffer == nullptr) {
            *error = U_MEMORY_ALLOCATION_ERROR;
            ucbuf_close(buf);
            return nullptr;
        }
        buf->currentPos=buf->buffer;
        buf->bufLimit=buf->buffer;
        if(U_FAILURE(*error)){
            fprintf(stderr, "Could not open codepage [%s]: %s\n", *cp, u_errorName(*error));
            ucbuf_close(buf);

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Always pass an explicit, canonical codepage string to ucbuf_open (e.g. "UTF-8") instead of leaving *cp null.
  2. Save the input as UTF-8/UTF-16 with a BOM so ucbuf_autodetect_fs succeeds and sets buf->conv.
  3. Keep showWarning=true during development so this fallback is surfaced, and treat it as a build error.
  4. Detect the encoding upstream with uchardet/file -i and feed that name as *cp.

Example fix

// before: no codepage, no BOM -> silent fallback to system codepage
const char* cp = nullptr;
UCHARBUF* b = ucbuf_open(path, &cp, true, false, &status);
// after: force UTF-8 explicitly
const char* cp = "UTF-8";
UCHARBUF* b = ucbuf_open(path, &cp, true, false, &status);
Defensive patterns

Strategy: fallback

Validate before calling

// Guarantee a usable converter before ucbuf_open by resolving cp yourself.
#include <unicode/ucnv.h>
const char* resolve_cp(const char* path, const char** cp) {
    // 1) if caller gave a non-empty, openable cp -> use it
    if (*cp && **cp) {
        UErrorCode e = U_ZERO_ERROR;
        UConverter* c = ucnv_open(*cp, &e);
        if (U_SUCCESS(e) && c) { ucnv_close(c); return *cp; }
    }
    // 2) else try UTF-8 (add BOM to files so this path is reliable)
    static const char* fb = "UTF-8";
    UErrorCode e = U_ZERO_ERROR;
    UConverter* c = ucnv_open(fb, &e);
    if (U_SUCCESS(e) && c) { ucnv_close(c); return fb; }
    return nullptr; // give up explicitly rather than rely on system codepage
}

Try / catch

// This is a warning, not a status failure -- it prints to stderr and continues.
// Detect it structurally: after ucbuf_open, verify a converter exists.
UCHARBUF* b = ucbuf_open(path, &cp, /*showWarning=*/true, false, &status);
if (U_SUCCESS(status) && b && /* buf->conv is null */ cp_was_null_and_no_bom) {
    fprintf(stderr, "refusing implicit system-codepage fallback\n");
    ucbuf_close(b);
    return EXIT_FAILURE;
}

Prevention

When it happens

Trigger: ucbuf_open called with *cp == nullptr or pointing to an empty string on a file that has no recognizable BOM, or with a *cp value ucnv_open silently returned null for; the converter ends up null and the rest of the pipeline assumes the system default codepage.

Common situations: An ICU data-building tool invoked without an encoding/-e flag on a plain ASCII/ANSI file lacking a BOM; deployment across OSes whose default codepage differs (Windows ACP vs Linux UTF-8); data files stripped of their BOM by a transfer pipeline.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/5007f29e6fe2d66e. Report an issue: GitHub.