Bug #172

Regular expressions should inherit encoding of context even if they only contain 7-bit chars

Added by Dave Thomas over 7 years ago. Updated over 4 years ago.

ruby -v: Backport:


The following program fails:

# encoding: utf-8
"∂y/∂x = 2x" =~ /\p{Greek}/

with "t.rb:2: invalid character property name {Greek}: /\p{Greek}/"

The reason is that the regexp has US-ASCII encoding, and in that encoding the property 'Greek' is not defined.

However, in this case, that's very unexpected behavior. I'd suggest that if a regular expression is US-ASCII, but is being compared to a string that is not US-ASCII, the regular expression should temporarily take on the same encoding as the string.



#1 Updated by Anonymous over 7 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r17882.

Also available in: Atom PDF