Index: encoding.c =================================================================== --- encoding.c (revision 31953) +++ encoding.c (working copy) @@ -1421,7 +1421,11 @@ const char *codeset = nl_langinfo_codeset(); char cp[sizeof(int) * 3 + 4]; if (!codeset) { - snprintf(cp, sizeof(cp), "CP%d", GetConsoleCP()); + UINT codepage = GetConsoleCP(); + if(codepage==0) { + codepage = GetACP(); + } + snprintf(cp, sizeof(cp), "CP%d", codepage); codeset = cp; } return rb_usascii_str_new2(codeset);