Project

General

Profile

Actions

Bug #20504

open

Interpolated string literal in regexp encoding handling

Added by kddnewton (Kevin Newton) about 1 month ago. Updated 24 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:117990]

Description

There is some very odd behavior that I'm not sure is intentional or not, so I'm looking for guidance. In here:

# encoding: us-ascii

interp = "\x80"
regexp = /#{interp}/

the regexp variable is a ascii-8bit regular expression with the byte interpolated into the middle. However, if you inline that interpolation:

# encoding: us-ascii

regexp = /#{"\x80"}/

you get a syntax error, saying it's an invalid multi-byte character. I'm not sure what the rule is here, as it seems inconsistent. Is this the correct behavior?

I would prefer if it would create an ascii-8bit regular expression like the first example, which would be consistent.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0