22#if defined _WIN32 || defined __CYGWIN__
23#define SIZEOF_CP_NAME ((sizeof(UINT) * 8 / 3) + 4)
24#define CP_FORMAT(buf, codepage) snprintf(buf, sizeof(buf), "CP%u", (codepage))
26extern UINT ruby_w32_codepage[2];
29#ifndef NO_LOCALE_CHARMAP
30# if defined _WIN32 || defined __CYGWIN__ || defined HAVE_LANGINFO_H
31# define NO_LOCALE_CHARMAP 0
33# define NO_LOCALE_CHARMAP 1
39locale_charmap(
VALUE (*conv)(
const char *))
41 const char *codeset = 0;
42#if defined _WIN32 || defined __CYGWIN__
43 char cp[SIZEOF_CP_NAME];
49 UINT codepage = ruby_w32_codepage[0];
50 if (!codepage) codepage = GetConsoleCP();
51 if (!codepage) codepage = GetACP();
52 CP_FORMAT(cp, codepage);
55#elif defined HAVE_LANGINFO_H
56 codeset = nl_langinfo(CODESET);
59# error locale_charmap() is not implemented
61 return (*conv)(codeset);
100#if !NO_LOCALE_CHARMAP
102enc_find_index(
const char *
name)
114 return (
int)locale_charmap(enc_find_index);
125 char cp[SIZEOF_CP_NAME];
126 const UINT codepage = ruby_w32_codepage[1] ? ruby_w32_codepage[1] :
127 AreFileApisANSI() ? GetACP() : GetOEMCP();
128 CP_FORMAT(cp, codepage);
131#elif defined __CYGWIN__
#define ENCINDEX_US_ASCII
int rb_enc_to_index(rb_encoding *enc)
rb_encoding * rb_default_external_encoding(void)
int rb_enc_find_index(const char *name)
const char * nl_langinfo_codeset(void)
VALUE rb_locale_charmap(VALUE klass)
int Init_enc_set_filesystem_encoding(void)
int rb_locale_charmap_index(void)