Ruby Newbie homepage Ruby Newbie homepage

How to use

Quick guide

Official content
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)
{
    int cr = rb_enc_str_coderange(str);

    return RBOOL(cr == ENC_CODERANGE_7BIT);
}
            

Was this page useful?