[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Matching multibyte alphabetical characters with LPeG
- From: Daurnimator <quae@...>
- Date: Sun, 17 Jun 2012 14:36:12 +1000
On 17 June 2012 13:40, Hinrik Örn Sigurðsson <firstname.lastname@example.org> 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: https://gist.github.com/2943418
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....