Project

General

Profile

Actions

Bug #2379

closed

String#[] returns invalid values for short multibyte strings

Added by raorn (Alexey Froloff) almost 15 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.1p333 (2009-11-02)
Backport:
[ruby-core:26787]

Description

=begin
In UTF-8 locale command
ruby -e 'print "ะน"[0,30]' | od -t x1
prints:

0000000 d0 b9 00 00
for ruby 1.9.1p333 (2009-11-02) [i586-linux-gnu]

0000000 d0 b9 00 00 00 00 00 00
for ruby 1.9.1p333 (2009-11-02) [x86_64-linux-gnu]

Minimum "len" to reproduce is 9 for i586 and 17 for x86_64.
=end


Related issues 2 (0 open2 closed)

Has duplicate Backport191 - Backport #3633: String accessor [Fixnum, Fixnum] produces wrong result in 1.9.1Closedyugui (Yuki Sonoda)Actions
Has duplicate Backport191 - Backport #4028: substring selection and utf8 encoding problemClosedyugui (Yuki Sonoda)Actions
Actions #1

Updated by raorn (Alexey Froloff) almost 15 years ago

=begin
"\u{444}" is better test string.
=end

Actions #2

Updated by naruse (Yui NARUSE) almost 15 years ago

  • Category set to M17N
  • Status changed from Open to Assigned
  • Assignee set to naruse (Yui NARUSE)
  • Target version set to 1.9.2

=begin

=end

Actions #3

Updated by raorn (Alexey Froloff) almost 15 years ago

=begin
This happens for all UTF-8 strings shorter than sizeof(VALUE) bytes and len greater than sizeof(VALUE)*2. Problem lies somewhere in str_utf8_nth() function.
=end

Actions #4

Updated by nobu (Nobuyoshi Nakada) almost 15 years ago

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

=begin
This issue was solved with changeset r25830.
Alexey, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0