Project

General

Profile

Actions

Backport #4028

closed

substring selection and utf8 encoding problem

Added by barcala (Fco. Mario Barcala Rodríguez) about 14 years ago. Updated over 5 years ago.

Status:
Closed
[ruby-core:33072]

Description

=begin
Substring selection does not work with some utf8 encoded strings. Below is an example. The first substring is well extracted but the second not (extrange characters appear at the end of the substring).

It seems it occurs when the string includes letters with umlauts, accents, etc.

$ irb

ruby-1.9.1-p378 > word = "Ábaco"
=> "Ábaco"
ruby-1.9.1-p378 > substr = word[word.length-1,word.length]
=> "o"
ruby-1.9.1-p378 > word = "Coordinador de ONG's do País Valenciano"
=> "Coordinador de ONG's do País Valenciano"
ruby-1.9.1-p378 > substr = word[word.length-1,word.length]
=> "o\x00\x00\x01\x00\x01\x00\x00\x00"
=end


Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #2379: String#[] returns invalid values for short multibyte stringsClosednaruse (Yui NARUSE)11/18/2009Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0