diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-28 10:12:13 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-28 10:12:13 +0000 |
commit | 371977ff3d76dda913442de13e7b71ab22c3ad4d (patch) | |
tree | 22d482edb4bef4c8c90cbb392c0c01a012ffc89e | |
parent | 6b54d4fd0b582d6fb002f5f373b30f044de7cd53 (diff) | |
download | ruby-371977ff3d76dda913442de13e7b71ab22c3ad4d.tar.gz |
* encoding.c (rb_locale_encoding): defined.
* include/ruby/encoding.h (rb_locale_encoding): declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | encoding.c | 12 | ||||
-rw-r--r-- | include/ruby/encoding.h | 1 |
3 files changed, 19 insertions, 0 deletions
@@ -1,3 +1,9 @@ +Fri Dec 28 19:11:28 2007 Tanaka Akira <akr@fsij.org> + + * encoding.c (rb_locale_encoding): defined. + + * include/ruby/encoding.h (rb_locale_encoding): declared. + Fri Dec 28 18:45:29 2007 NAKAMURA Usaku <usa@ruby-lang.org> * ext/readline/readline.c (readline_readline): set encoding to result. 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 * diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h index 1a57876555..50516b3c0a 100644 --- a/include/ruby/encoding.h +++ b/include/ruby/encoding.h @@ -123,6 +123,7 @@ int rb_enc_str_asciionly_p(VALUE); VALUE rb_enc_from_encoding(rb_encoding *enc); rb_encoding *rb_ascii8bit_encoding(void); rb_encoding *rb_utf8_encoding(void); +rb_encoding *rb_locale_encoding(void); rb_encoding *rb_default_external_encoding(void); VALUE rb_enc_default_external(void); void rb_enc_set_default_external(VALUE encoding); |