From: Daniel DeLorme Date: 2007-12-06T09:15:52+09:00 Subject: Re: Unicode in Regex marc wrote: > Daniel DeLorme said... >> MonkeeSage wrote: >>> Everything in ruby is a bytestring. >> YES! And that's exactyly how it should be. Who is it that spread the >> flawed idea that strings are fundamentally made of characters? > > Are you being ironic? Not at all. By "fundamentally" I mean the fundamental, lowest level of representation. If strings were fundamentally made of characters then we wouldn't be able to access individual bytes because that's a lower level than the fundamental level, which is by definition impossible. If you are using UCS2 it makes sense to consider strings as arrays of characters because that's what they are. But UTF8 strings do not follow the characteristics of arrays at all. Each access into the "array" is O(n) rather than O(1). So IMHO treating it as an array of characters is a *very* leaky abstraction. I agree that 99.9% of the time you want to deal with characters, and I believe that in 99% of those cases you would be better served with regex than this pretend "array" disguise. Daniel