1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* string.c (rb_str_is_ascii_only_p): new method ascii_only?.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2007-12-21 03:18:37 +00:00
parent f2515d9938
commit 2b62714866
2 changed files with 13 additions and 0 deletions

View file

@ -1,3 +1,7 @@
Fri Dec 21 12:16:50 2007 Tanaka Akira <akr@fsij.org>
* string.c (rb_str_is_ascii_only_p): new method ascii_only?.
Fri Dec 21 12:00:34 2007 Tanaka Akira <akr@fsij.org>
* configure.in: check langinfo.h and locale.h.

View file

@ -5341,6 +5341,14 @@ rb_str_valid_encoding_p(VALUE str)
return cr == ENC_CODERANGE_BROKEN ? Qfalse : Qtrue;
}
static VALUE
rb_str_is_ascii_only_p(VALUE str)
{
int cr = rb_enc_str_coderange(str);
return cr == ENC_CODERANGE_7BIT ? Qtrue : Qfalse;
}
/**********************************************************************
* Document-class: Symbol
*
@ -5754,6 +5762,7 @@ Init_String(void)
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);
rb_define_method(rb_cString, "valid_encoding?", rb_str_valid_encoding_p, 0);
rb_define_method(rb_cString, "ascii_only?", rb_str_is_ascii_only_p, 0);
id_to_s = rb_intern("to_s");