2

As part of a larger parser, I am writing a rule to match strings like the following using parboiled2:

Italiana Relè

I would like to use something simple like the following:

CharPredicate.Printable

But the parser is failing with an org.parboiled2.ParseError because of the unicode character at the end of the string.

Is there a simple option that I'm not aware of for matching printable unicode characters?

David
  • 13,133
  • 1
  • 30
  • 39

1 Answers1

1

Take a look at https://github.com/sirthias/parboiled2/blob/master/parboiled-core/src/main/scala/org/parboiled2/CharPredicate.scala#L112 - it is very easy to do your own predicates, for instance:

val latinSupplementCharsPredicate = CharPredicate('\u00c0' to '\u00dc') ++ CharPredicate('\u00e0' to '\u00fd')
abatyuk
  • 1,342
  • 9
  • 16
  • Thanks! I had just figured that out before I saw your answer! That's so nice! – David Jan 16 '15 at 23:51
  • 1
    Good luck. Please also take note that different countries have different characters, so you may want to customize the Unicode selection to a specific set, and keep extra chars out to validate the data. – abatyuk Jan 17 '15 at 02:28