From 84820319789e6ba191ace5744c2e14be1a5f274e Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 27 Aug 2007 06:56:49 +0000 Subject: * string.c (sym_encoding): return the encoding of a Symbol. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'string.c') diff --git a/string.c b/string.c index 11c80d461..653f4c067 100644 --- a/string.c +++ b/string.c @@ -5171,6 +5171,12 @@ sym_swapcase(VALUE sym) return rb_str_intern(rb_str_swapcase(rb_id2str(SYM2ID(sym)))); } +static VALUE +sym_encoding(VALUE sym) +{ + return str_encoding(rb_id2str(SYM2ID(sym))); +} + ID rb_to_id(VALUE name) { @@ -5367,5 +5373,5 @@ Init_String(void) rb_define_method(rb_cSymbol, "capitalize", sym_capitalize, 0); rb_define_method(rb_cSymbol, "swapcase", sym_swapcase, 0); - rb_define_method(rb_cSymbol, "encoding", str_encoding, 0); + rb_define_method(rb_cSymbol, "encoding", sym_encoding, 0); } -- cgit