Method: Regexp#fixed_encoding?
- Defined in:
- re.c
#fixed_encoding? ⇒ Boolean
Returns false
if self
is applicable to a string with any ASCII-compatible encoding; otherwise returns true
:
r = /a/ # => /a/
r.fixed_encoding? # => false
r.match?("\u{6666} a") # => true
r.match?("\xa1\xa2 a".force_encoding("euc-jp")) # => true
r.match?("abc".force_encoding("euc-jp")) # => true
r = /a/u # => /a/
r.fixed_encoding? # => true
r.match?("\u{6666} a") # => true
r.match?("\xa1\xa2".force_encoding("euc-jp")) # Raises exception.
r.match?("abc".force_encoding("euc-jp")) # => true
r = /\u{6666}/ # => /\u{6666}/
r.fixed_encoding? # => true
r.encoding # => #<Encoding:UTF-8>
r.match?("\u{6666} a") # => true
r.match?("\xa1\xa2".force_encoding("euc-jp")) # Raises exception.
r.match?("abc".force_encoding("euc-jp")) # => false
1564 1565 1566 1567 1568 |
# File 're.c', line 1564 static VALUE rb_reg_fixed_encoding_p(VALUE re) { return RBOOL(FL_TEST(re, KCODE_FIXED)); } |