summaryrefslogtreecommitdiffstats
path: root/encoding.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-04 06:41:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-04 06:41:43 +0000
commita91ce21ec22cec9fbc4c3a05ae8f66d295e54109 (patch)
treeab9f25de9937dbd6b0415dcf0abed0d568ab5ae0 /encoding.c
parentf7c6aee5c0ee391d3f1c0649d8823834c918f6fb (diff)
downloadruby-a91ce21ec22cec9fbc4c3a05ae8f66d295e54109.tar.gz
ruby-a91ce21ec22cec9fbc4c3a05ae8f66d295e54109.tar.xz
ruby-a91ce21ec22cec9fbc4c3a05ae8f66d295e54109.zip
* encoding.c (rb_filesystem_encoding, rb_locale_charmap): uses
codepage on cygwin. [ruby-core:20994] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@21311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/encoding.c b/encoding.c
index eca4140a0..73eda32cb 100644
--- a/encoding.c
+++ b/encoding.c
@@ -13,11 +13,19 @@
#include "ruby/encoding.h"
#include "regenc.h"
#include <ctype.h>
-#ifdef HAVE_LANGINFO_H
+#ifndef NO_LOCALE_CHARMAP
+#if defined __CYGWIN__
+#include <windows.h>
+#elif defined 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;
@@ -1025,7 +1033,7 @@ rb_encoding *
rb_filesystem_encoding(void)
{
rb_encoding *enc;
-#if defined _WIN32
+#if defined USE_CODEPAGE_LOCALE
enc = rb_locale_encoding();
#elif defined __APPLE__
enc = rb_enc_find("UTF8-MAC");
@@ -1204,12 +1212,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