diff --git a/ChangeLog b/ChangeLog index 38b3b0e029..abb0508be6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Jun 10 16:38:13 2011 NARUSE, Yui + + * encoding.c (rb_locale_charmap): When ruby process is run as Windows + Service the console codepage is not set, GetConsoleCP returns 0. + So on such environment, use GetACP(). + http://blogs.msdn.com/b/michkap/archive/2005/02/08/369197.aspx + patched by Rafal Bigaj [ruby-core:36832] [Bug #4854] + Fri Jun 10 14:34:24 2011 Koichi Sasada * common.mk: restore TESTRUN_SCRIPT to "$(srcdir)/test.rb". diff --git a/encoding.c b/encoding.c index a88d176c0f..d152d77321 100644 --- a/encoding.c +++ b/encoding.c @@ -1427,7 +1427,9 @@ rb_locale_charmap(VALUE klass) 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) codepage = GetACP(); + snprintf(cp, sizeof(cp), "CP%d", codepage); codeset = cp; } return rb_usascii_str_new2(codeset);