Bug #2379
String#[] returns invalid values for short multibyte strings
| Status: | Closed | Start date: | 11/18/2009 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | M17N | |||
| Target version: | 1.9.2 | |||
| ruby -v: | ruby 1.9.1p333 (2009-11-02) |
Description
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.
Related issues
Associated revisions
* string.c (str_utf8_nth): fixed overrun. [ruby-core:26787]
?\012
* string.c (str_utf8_nth): no count_utf8_lead_bytes_with_word
optimization for short string. [ruby-core:26787]
* string.c (str_utf8_offset): str_utf8_nth never return NULL.
?\012
History
Updated by raorn (Alexey Froloff) over 2 years ago
"\u{444}" is better test string.
Updated by naruse (Yui NARUSE) over 2 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
Updated by raorn (Alexey Froloff) over 2 years ago
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.
Updated by nobu (Nobuyoshi Nakada) over 2 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
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.