lua-users home
lua-l archive

Re: Is it possible to add utf-8 lua source file support in lua 5.2?

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


Luiz Henrique de Figueiredo schrieb:
> In Lua 5.2 you don't even have to patch the lexer: just edit lctype.c
> and say that 0xFF and 0xFE are whitespace. This of course is not the
> perfect solution, because BOM is a 2-byte entity, not a 1-byte one...
In UTF-8 the BOM is encoded as 3 bytes. I use this LPeg expression for
space including the BOM:
local Space = (g.S " \n\r\t" + g.P "239円187円191円")^0
(g is a local shortcut for the lpeg module)
-- David

AltStyle によって変換されたページ (->オリジナル) /