summaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-10 07:42:24 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-10 07:42:24 +0000
commitc479bde4fe6486f2067c8a519714ee35e0411646 (patch)
treefa941bc0e54f27925e190728ba5e044b5f97d12f /encoding.c
parent09c8651387bed889bd3f4763962d8ce73bd348b3 (diff)
* 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c4
1 files changed, 3 insertions, 1 deletions
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);