lua-users home
lua-l archive

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

On 17 June 2012 13:40, Hinrik Örn Sigurðsson <> wrote:
> I've been making a parser with LPeG and I've run into the issue that I can't
> match non-ASCII words even though I'm using a utf8 locale. It seems that
> "alpha" (and "alnum", etc) from lpeg.locale() don't match anything beyond ASCII.
> See the following code:
>    local lpeg = require 'lpeg'
>    local locale = lpeg.locale()
>    print(lpeg.match(lpeg.C(lpeg.P("æ")), "æ"))    --> æ
>    print(lpeg.match(lpeg.C(locale.alpha), "æ"))   --> nil
> Is there an easy way to match non-ASCII alphabetical characters with LPeG?
> If not, can LPeG be patched to support it?

Your question on IRC prompted me to write this:
Uses the example from the lpeg docs (UTF-8 and Unicode) and the ffi
(cause it's so easy).
Should be easy enough to adapt to ICU4Lua or such....