ruby-changes:2891
From: ko1@a...
Date: 21 Dec 2007 12:18:51 +0900
Subject: [ruby-changes:2891] akr - Ruby:r14383 (trunk): * string.c (rb_str_is_ascii_only_p): new method ascii_only?.
akr 2007-12-21 12:18:37 +0900 (Fri, 21 Dec 2007) New Revision: 14383 Modified files: trunk/ChangeLog trunk/string.c Log: * string.c (rb_str_is_ascii_only_p): new method ascii_only?. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/string.c?r1=14383&r2=14382 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14383&r2=14382 Index: ChangeLog =================================================================== --- ChangeLog (revision 14382) +++ ChangeLog (revision 14383) @@ -1,3 +1,7 @@ +Fri Dec 21 12:16:50 2007 Tanaka Akira <akr@f...> + + * string.c (rb_str_is_ascii_only_p): new method ascii_only?. + Fri Dec 21 12:00:34 2007 Tanaka Akira <akr@f...> * configure.in: check langinfo.h and locale.h. Index: string.c =================================================================== --- string.c (revision 14382) +++ string.c (revision 14383) @@ -5341,6 +5341,14 @@ 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 @@ 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"); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml