From: nobu@... Date: 2014-06-04T13:05:59+00:00 Subject: [ruby-dev:48278] [ruby-trunk - Bug #9903] [Open] Regexp#[] doesn't consider capture name encoding Issue #9903 has been reported by Nobuyoshi Nakada. ---------------------------------------- Bug #9903: Regexp#[] doesn't consider capture name encoding https://bugs.ruby-lang.org/issues/9903 * Author: Nobuyoshi Nakada * Status: Open * Priority: Normal * Assignee: * Category: * Target version: * ruby -v: r46343 * Backport: 2.0.0: REQUIRED, 2.1: REQUIRED ---------------------------------------- Regexp#[]が引数の文字列やシンボルを考慮していません。 ~~~ruby key = "\xb1\xb2".force_encoding(Encoding::EUC_JP) m = /(?<#{key}>.*)/.match("xxx") p m[key.dup.force_encoding(Encoding::Shift_JIS)] # => "xxx" ~~~ -- https://bugs.ruby-lang.org/