aboutsummaryrefslogtreecommitdiffstats
path: root/localeinit.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-31 00:35:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-31 00:35:02 +0000
commit2009b8cabf04e0ea02fb49071f79218ecd47bfd6 (patch)
tree2c37a87d21e7022de7a4d5bb99417400b5b1f5a6 /localeinit.c
parent713700c41c0ac61b55ab4795b3c6407e66a30d5d (diff)
downloadruby-2009b8cabf04e0ea02fb49071f79218ecd47bfd6.tar.gz
RUBY_DEBUG codepage option [ci skip]
* debug.c (set_debug_option): add "codepage" option to force locale charmap on Windows. * localeinit.c (locale_charmap): use the codepage by debug env if given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'localeinit.c')
-rw-r--r--localeinit.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/localeinit.c b/localeinit.c
index 394d8dc7d6..fa9cc26b8e 100644
--- a/localeinit.c
+++ b/localeinit.c
@@ -23,6 +23,12 @@
#define CP_FORMAT(buf, codepage) snprintf(buf, sizeof(buf), "CP%u", (codepage))
#endif
+#if defined _WIN32 && defined RUBY_DEBUG_ENV
+extern UINT ruby_w32_codepage;
+#else
+enum {ruby_w32_codepage = 0};
+#endif
+
#ifndef NO_LOCALE_CHARMAP
# if defined _WIN32 || defined __CYGWIN__ || defined HAVE_LANGINFO_H
# define NO_LOCALE_CHARMAP 0
@@ -43,7 +49,8 @@ locale_charmap(VALUE (*conv)(const char *))
codeset = nl_langinfo_codeset();
# endif
if (!codeset) {
- UINT codepage = GetConsoleCP();
+ UINT codepage = ruby_w32_codepage;
+ if (!codepage) codepage = GetConsoleCP();
if (!codepage) codepage = GetACP();
CP_FORMAT(cp, codepage);
codeset = cp;
@@ -119,7 +126,9 @@ Init_enc_set_filesystem_encoding(void)
idx = ENCINDEX_US_ASCII;
#elif defined _WIN32
char cp[SIZEOF_CP_NAME];
- CP_FORMAT(cp, AreFileApisANSI() ? GetACP() : GetOEMCP());
+ const UINT codepage = ruby_w32_codepage ? ruby_w32_codepage :
+ AreFileApisANSI() ? GetACP() : GetOEMCP();
+ CP_FORMAT(cp, codepage);
idx = rb_enc_find_index(cp);
if (idx < 0) idx = ENCINDEX_ASCII;
#elif defined __CYGWIN__