Caio Chassot wrote:
> Should this be considered a bug in StringScanner? Wouldn't it make more
> sense for it to use character indexes?

I suspect the reason it does it this way is because it's very expensive 
in ruby 1.9 to jump to the Nth character. So if you were scanning a 
large string, it would get slower and slower as you scanned further 
along, calling #scan each time.

I think what you're doing is the only option: tag the string as a 
single-byte encoding ("ASCII-8BIT" would be better than "US-ASCII"), 
select the range of bytes, and tag it back again, relying on the fact 
that strscan has chomped a whole number of characters.
-- 
Posted via http://www.ruby-forum.com/.