summaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-09 02:18:30 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-09 02:18:30 +0000
commit4e057854102f9c4178e03583569ac6a814f732b0 (patch)
tree16616f4178b90ace40527f1192d5271a6a5092e6 /encoding.c
parente28983e065bd8a37bed5d50e8c3703e6a6d5c548 (diff)
merges r21110 from trunk into ruby_1_9_1.
* encoding.c (rb_filesystem_encoding): use ANSI codepage for file system on cygwin. * encoding.c (rb_locale_charmap): reverted. [ruby-core:21110] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/encoding.c b/encoding.c
index 73eda32cb4..fde7103609 100644
--- a/encoding.c
+++ b/encoding.c
@@ -14,18 +14,15 @@
#include "regenc.h"
#include <ctype.h>
#ifndef NO_LOCALE_CHARMAP
-#if defined __CYGWIN__
+#ifdef __CYGWIN__
#include <windows.h>
-#elif defined HAVE_LANGINFO_H
+#endif
+#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
#endif
#endif
#include "ruby/util.h"
-#if defined _WIN32 || defined __CYGWIN__
-#define USE_CODEPAGE_LOCALE 1
-#endif
-
static ID id_encoding;
VALUE rb_cEncoding;
static VALUE rb_encoding_list;
@@ -1033,8 +1030,12 @@ rb_encoding *
rb_filesystem_encoding(void)
{
rb_encoding *enc;
-#if defined USE_CODEPAGE_LOCALE
- enc = rb_locale_encoding();
+#if defined NO_LOCALE_CHARMAP
+ enc = rb_default_external_encoding();
+#elif defined _WIN32 || defined __CYGWIN__
+ char cp[sizeof(int) * 8 / 3 + 4];
+ snprintf(cp, sizeof cp, "CP%d", GetACP());
+ enc = rb_enc_find(cp);
#elif defined __APPLE__
enc = rb_enc_find("UTF8-MAC");
#else
@@ -1212,12 +1213,12 @@ rb_locale_charmap(VALUE klass)
{
#if defined NO_LOCALE_CHARMAP
return rb_usascii_str_new2("ASCII-8BIT");
-#elif defined USE_CODEPAGE_LOCALE
- return rb_sprintf("CP%d", GetACP());
#elif defined HAVE_LANGINFO_H
char *codeset;
codeset = nl_langinfo(CODESET);
return rb_usascii_str_new2(codeset);
+#elif defined _WIN32
+ return rb_sprintf("CP%d", GetACP());
#else
return Qnil;
#endif