lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Friday 18 February 2005 19:03, PA wrote:
> >> Ok. But that seems to imply that I have to forgo Lua's string library
> >> altogether and use the above library instead. Is that a drop in
> >> replacement? Just asking :))
> >
> > In principle yes -- to the extend where any
> > data used with string is really UTF-8 character data
> > (and once the mentioned todos are done).
> > In practice this is looking for trouble, as it would break other
> > libs using string to cut arbitrary bytes out of something.
>
> So... what does that mean? Most (all?) Lua extensions are build in
> terms of the default string API, no?
probably

> Does the entire string library needs to be hijacked?
no, don't do it.
Most uses will really mean to work on bytes,
regardless of their content,
and these could get very confused by such hijacking.

In principle there could be some libs actually wanting
to strip, say, the first ten *characters* from a string
(regardless of how many bytes that may be)
or, maybe less exotic, to lowercase everything.

Maybe it would be nice to have the encoding independent
functions rep, dump, and bytewise sub, len and reverse
in a package "bytes" so as to replace "string" with whatever
seems fit. However, assume "string" to mean "bytes",
and to maximize confusion do "ctype = utf8" and patch
around libs to use "ctype" instead of "string". Anyway,
such libs better accept a ctype module as parameter.


> Staff or stuff? :P
just quoting your server's X-Powered-by header

> > doesn't look like there's too much need to manipulate the texts?
> Indexing? Search?
can be done regardless of content.
Only normalization and collation would require some more.

> Reading and writing to disk? Reading and writing to sockets?
no manipulation there. just pass bytes on.


saludos