diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-22 08:38:53 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-22 08:38:53 +0000 |
| commit | 81aeb1bf3d59a962a3fd7727e931f8842ded8c9f (patch) | |
| tree | 024fe8440cec06e4478f0729ee1b96d2caf72509 /string.c | |
| parent | 8c547e3c0a535ca0c0c118be94ca13fd79d0f035 (diff) | |
| download | ruby-81aeb1bf3d59a962a3fd7727e931f8842ded8c9f.tar.gz ruby-81aeb1bf3d59a962a3fd7727e931f8842ded8c9f.tar.xz ruby-81aeb1bf3d59a962a3fd7727e931f8842ded8c9f.zip | |
add rdoc.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
| -rw-r--r-- | string.c | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -501,8 +501,7 @@ rb_str_length(VALUE str) */ static VALUE -rb_str_bytesize(str) - VALUE str; +rb_str_bytesize(VALUE str) { return INT2NUM(RSTRING_LEN(str)); } @@ -5341,6 +5340,17 @@ rb_str_force_encoding(VALUE str, VALUE enc) 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 @@ rb_str_valid_encoding_p(VALUE str) 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) { |
