ruby-changes:2990
From: ko1@a...
Date: 22 Dec 2007 17:39:01 +0900
Subject: [ruby-changes:2990] akr - Ruby:r14482 (trunk): add rdoc.
akr 2007-12-22 17:38:53 +0900 (Sat, 22 Dec 2007)
New Revision: 14482
Modified files:
trunk/string.c
Log:
add rdoc.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/string.c?r1=14482&r2=14481
Index: string.c
===================================================================
--- string.c (revision 14481)
+++ string.c (revision 14482)
@@ -501,8 +501,7 @@
*/
static VALUE
-rb_str_bytesize(str)
- VALUE str;
+rb_str_bytesize(VALUE str)
{
return INT2NUM(RSTRING_LEN(str));
}
@@ -5341,6 +5340,17 @@
return str;
}
+/*
+ * call-seq:
+ * str.valid_encoding? => true or false
+ *
+ * Returns true for a string which encoded correctly.
+ *
+ * "\xc2\xa1".force_encoding("UTF-8").valid_encoding? => true
+ * "\xc2".force_encoding("UTF-8").valid_encoding? => false
+ * "\x80".force_encoding("UTF-8").valid_encoding? => false
+ */
+
static VALUE
rb_str_valid_encoding_p(VALUE str)
{
@@ -5349,6 +5359,16 @@
return cr == ENC_CODERANGE_BROKEN ? Qfalse : Qtrue;
}
+/*
+ * call-seq:
+ * str.ascii_only? => true or false
+ *
+ * Returns true for a string which has only ASCII characters.
+ *
+ * "abc".force_encoding("UTF-8").ascii_only? => true
+ * "abc\u{6666}".force_encoding("UTF-8").ascii_only? => false
+ */
+
static VALUE
rb_str_is_ascii_only_p(VALUE str)
{
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml