Instance method
# ascii_only?
Returns true for a string which has only ASCII characters.
How to use
Quick guide
Official content
Official how?
I scraped all this data from the official documentation. I created this site to make it easier for beginners and more pleasant for professionals to use Ruby.
Georgie boy
Creator of ruby-docs.org
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?
Leave your feedback
Please hit 'submit' to confirm your feedback.
Leave your feedback
Please hit 'submit' to confirm your feedback.