Feature #3619: \x{XXXX} as an escape sequence of string
http://redmine.ruby-lang.org/issues/show/3619

Author: Heesob Park
Status: Open, Priority: Low
Category: core, Target version: 1.9.x

I noticed String#inspect results \x{XXXX} for the encoding other than Unicode.

Is there any possibility that \x{XXXX} is accepted as an escape sequence of string?

irb(main):004:0> a = "\xC7\xD1\xB1\xDB"
=> "\xC7ѱ\xDB"
irb(main):005:0> a.encoding
=> #<Encoding:UTF-8>
irb(main):006:0> a.force_encoding('EUC-KR')
=> "\x{C7D1}\x{B1DB}"
irb(main):007:0> a.encode('UTF-8')
=> "????"
irb(main):008:0> a
=> "\x{C7D1}\x{B1DB}"
irb(main):009:0> a[0]
=> "\x{C7D1}"
irb(main):010:0> a[1]
=> "\x{B1DB}"
irb(main):011:0> b = "\x{B1DB}"
SyntaxError: (irb):11: invalid hex escape
b = "\x{B1DB}"
       ^
	from /usr/local/bin/irb:12:in `<main>'


----------------------------------------
http://redmine.ruby-lang.org