[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: String indexing again
- From: steve donovan <steve.j.donovan@...>
- Date: Mon, 20 Dec 2010 10:44:04 +0200
On Mon, Dec 20, 2010 at 10:01 AM, Dirk Laurie <email@example.com> wrote:
> I suppose that is the portable way. OK, I'll shut up on this topic
As a last gasp, it's not difficult to write a custom type that does
provide index access to string 'characters' (modulo UTF-8 etc )
You use it like this:
sa = StringAccessor 'hello'
for c in sa:iter() do -- (see )
 This kind of pattern would be useful for wrapping strings so that
one could properly extract non-ASCII characters....
 With Lua 5.2, ipairs can be overriden as well, making string
accessors more 'table-like'