Skip to content

Express Unicode codepoints over 0xFFFF #354

Answered by pdubroy
iacore asked this question in Help
Discussion options

You must be logged in to vote

(Caveat: I'm bumping up against the limits of my Unicode knowledge here, but I wanted to respond quickly so I can understand a bit more about your use case before I do some more reading.)

It depends a bit on what exactly you're trying to do. You can embed those characters directly in a terminal expression, and that should work. E.g.:

ohm.grammar('G { start = "😀" }').match('😀').succeeded() // true

You can also encode it as a surrogate pair (same as in ES5 and JSON). E.g., assume you have the following grammar in g.ohm:

G {
  start = "\uD83D\uDE00"
}

..then this will work:

ohm.grammar(fs.readFileSync('g.ohm', 'utf-8')).match('😀').succeeded() // true

What we don't yet support properly is r…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
7 replies
@iacore
Comment options

@pdubroy
Comment options

@pdubroy
Comment options

@iacore
Comment options

@pdubroy
Comment options

Answer selected by pdubroy
Comment options

You must be logged in to vote
1 reply
@iacore
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #353 on January 10, 2022 18:55.