lua-users home
lua-l archive

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


Edgar Toernig wrote:
> I know that Lua's authors try to avoid bloat, but these additional
> 176 bytes (that's what an implementation of the \u4x/\U8x variant on
> x86-32 costs) are IMHO very well spent.

It's not just those 176 bytes. To support UTF-8 properly the string
pattern functions (find, match, ...) would also need to recognize UTF-8
characters as single characters in character sets. And then you would
need to extend all the predefined classes (%a, %c, %g, ...). This
updated pattern matching would break the classic C character handling.

To avoid incompatibilities a second version of the pattern matching
functions would be needed. (Though I guess they could share a lot of
code). Maybe this could be a compile time option.

A half baked solution (just escapes, not patterns) should be avoided in
my opinion, as I guess many users will try something like
string.match(s, "[\u2013\u2026]").

-- David