summaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-10-04 06:57:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-10-04 06:57:19 +0000
commit19dee8af57634c5813286ffbb63cc82611748378 (patch)
tree0683f9609b4761db95c734f093f55459778cd1d1 /encoding.c
parent612b2ed6a751629b2809e58a8f42a56e8690e8c7 (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 'encoding.c')
-rw-r--r--encoding.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/encoding.c b/encoding.c
index 6f7b406c88..70309f4f6f 100644
--- a/encoding.c
+++ b/encoding.c
@@ -259,6 +259,20 @@ rb_enc_copy(VALUE obj1, VALUE obj2)
}
+/*
+ * call-seq:
+ * obj.encoding => str
+ *
+ * Retruns the encoding name.
+ */
+
+VALUE
+rb_obj_encoding(VALUE obj)
+{
+ return rb_str_new2(rb_enc_name(rb_enc_get(obj)));
+}
+
+
char*
rb_enc_nth(const char *p, const char *e, int nth, rb_encoding *enc)
{