1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
naruse 2011-06-10 07:42:24 +00:00
parent 09c8651387
commit c479bde4fe
2 changed files with 11 additions and 1 deletions

View file

@ -1,3 +1,11 @@
Fri Jun 10 16:38:13 2011 NARUSE, Yui <naruse@ruby-lang.org>
* 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 <ko1@atdot.net>
* common.mk: restore TESTRUN_SCRIPT to "$(srcdir)/test.rb".

View file

@ -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);