Issue #9903 has been updated by Usaku NAKAMURA.
Backport changed from 2.0.0: REQUIRED, 2.1: DONE to 2.0.0: DONE, 2.1:
DONE
backported into ruby_2_0_0
at r47364.
note that it needed r42251.
Bug #9903: Regexp#[] doesn’t consider capture name encoding
- Author: Nobuyoshi N.
- Status: Closed
- Priority: Normal
- Assignee:
- Category:
- Target version:
- ruby -v: r46343
- Backport: 2.0.0: DONE, 2.1: DONE
Regexp#[]が引数の文字列やシンボルを考慮していません。
key = "\xb1\xb2".force_encoding(Encoding::EUC_JP)
m = /(?<#{key}>.*)/.match("xxx")
p m[key.dup.force_encoding(Encoding::Shift_JIS)]
# => "xxx"