On Sep 26, 2006, at 12:15 PM, Newbie wrote:
> Why not a 1-character string?
Even if String#[index] returned a 1-character string, you would still
want a way to extract individual code-points/bytes. Right now you have:
s[i..i] # substring starting at position i of length 1
s[i] # code-point at position i
I think in future Ruby versions it is going to be something like:
s[i..i] # substring starting at position i of length 1
s[i] # same as s[i..i]
s.byte(i) # code-point at position i
I'm guessing at String#byte. I know I read something about that but I
couldn't find a reference right away.
Anyway, as I understand it, the concept of 'character' or even
'position'
is pretty complicated in a fully i18n world (such as with Unicode).
Gary Wright