diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-15 15:39:38 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-15 15:39:38 +0000 |
| commit | df63499b2e7ac2e207cacec7e1090793d44b8298 (patch) | |
| tree | 18f05578b99866475103d7c46eb0d8b9ca82f79b /encoding.c | |
| parent | 89d353bc7f5f616b01c2433f0d364e7ebaf6de49 (diff) | |
merges r21511 from trunk into ruby_1_9_1.
* encoding.c (rb_locale_charmap): fallback to codepage if no
locale is found. [ruby-core:21110]
* missing/langinfo.c (nl_langinfo_codeset): returns NULL if no
locale is found.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@21563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
| -rw-r--r-- | encoding.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/encoding.c b/encoding.c index 6c70c7413..858f4e70e 100644 --- a/encoding.c +++ b/encoding.c @@ -1218,6 +1218,15 @@ rb_locale_charmap(VALUE klass) { #if defined NO_LOCALE_CHARMAP return rb_usascii_str_new2("ASCII-8BIT"); +#elif defined __CYGWIN__ + const char *nl_langinfo_codeset(void); + const char *codeset = nl_langinfo_codeset(); + char cp[sizeof(int) * 3 + 4]; + if (codeset) { + snprintf(cp, sizeof(cp), "CP%d", GetConsoleCP()); + codeset = cp; + } + return rb_usascii_str_new2(codeset); #elif defined HAVE_LANGINFO_H char *codeset; codeset = nl_langinfo(CODESET); |
