diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-10-04 06:57:19 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-10-04 06:57:19 +0000 |
commit | 19dee8af57634c5813286ffbb63cc82611748378 (patch) | |
tree | 0683f9609b4761db95c734f093f55459778cd1d1 /string.c | |
parent | 612b2ed6a751629b2809e58a8f42a56e8690e8c7 (diff) |
* encoding.c (rb_obj_encoding): returns encoding of the given object.
* re.c (Init_Regexp): new method Regexp#encoding.
* string.c (str_encoding): moved to encoding.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 18 |
1 files changed, 2 insertions, 16 deletions
@@ -5108,20 +5108,6 @@ rb_str_setter(VALUE val, ID id, VALUE *var) /* * call-seq: - * str.encoding => str - * - * Retruns the encoding name. - */ - -static VALUE -str_encoding(VALUE str) -{ - return rb_str_new2(rb_enc_name(rb_enc_get(str))); -} - - -/* - * call-seq: * str.force_encoding(encoding) => str * * Changes the encoding to +encoding+ and returns self. @@ -5388,7 +5374,7 @@ sym_swapcase(VALUE sym) static VALUE sym_encoding(VALUE sym) { - return str_encoding(rb_id2str(SYM2ID(sym))); + return rb_obj_encoding(rb_id2str(SYM2ID(sym))); } ID @@ -5545,7 +5531,7 @@ Init_String(void) rb_define_method(rb_cString, "partition", rb_str_partition, 1); rb_define_method(rb_cString, "rpartition", rb_str_rpartition, 1); - rb_define_method(rb_cString, "encoding", str_encoding, 0); + rb_define_method(rb_cString, "encoding", rb_obj_encoding, 0); /* in encoding.c */ rb_define_method(rb_cString, "force_encoding", rb_str_force_encoding, 1); id_to_s = rb_intern("to_s"); |