Project

General

Profile

Bug #8138

rpartition(regexp) for multibyte string

Added by no6v (Nobuhiro IMAI) almost 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.0dev (2013-03-21 trunk 39858) [x86_64-linux]
Backport:
[ruby-dev:47183]

Description

=begin
以下のように、String#rpartition に正規表現を渡したとき、マルチバイト文字列だと挙動がおかしいようです。

# encoding: UTF-8
"user@domain".partition("@") # => ["user", "@", "domain"]
"user@domain".partition(/@/) # => ["user", "@", "domain"]
"user@domain".rpartition("@") # => ["user", "@", "domain"]
"user@domain".rpartition(/@/) # => ["user", "@", "domain"]
"ユーザ@ドメイン".partition("@") # => ["ユーザ", "@", "ドメイン"]
"ユーザ@ドメイン".partition(/@/) # => ["ユーザ", "@", "ドメイン"]
"ユーザ@ドメイン".rpartition("@") # => ["ユーザ", "@", "ドメイン"]
"ユーザ@ドメイン".rpartition(/@/) # => ["ユーザ@ドメイン", "@", nil]
=end

#1

Updated by knu (Akinori MUSHA) almost 7 years ago

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

This issue was solved with changeset r39903.
Nobuhiro, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


Fix String#rpartition(/re/) against a multibyte string.

  • string.c (rb_str_rpartition): Fix String#rpartition(/re/) against a multibyte string. [Bug #8138] [ruby-dev:47183]

Also available in: Atom PDF