lua-users home
lua-l archive

[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