diff options
Diffstat (limited to 'encoding.c')
-rw-r--r-- | encoding.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/encoding.c b/encoding.c index 3070af55ac..adbad670f1 100644 --- a/encoding.c +++ b/encoding.c @@ -853,6 +853,18 @@ rb_utf8_encoding(void) return enc_table[ENCINDEX_UTF8].enc; } +rb_encoding * +rb_locale_encoding(void) +{ + VALUE charmap = rb_locale_charmap(rb_cEncoding); + int idx = rb_enc_find_index(StringValueCStr(charmap)); + + if (idx < 0) + return rb_ascii8bit_encoding(); + + return rb_enc_from_index(idx); +} + static int default_external_index; rb_encoding * |