Open bwbaugh opened 6 years ago
I’ve come up with a very hacky workaround just to unblock myself to see if I can use this library on that file that I’m interested in. A proper solution would probably use a parser, perhaps similar to https://stackoverflow.com/q/24106314/1988505.
The issue is that
pQuotedString
usesreads
, which tries to interpret a quoted string as a Haskell style string literal, instead of using aParsec
parser.https://github.com/jan-christiansen/nextstep-plist/blob/48ec35d583d1c5857ed22fc182be25c2db3743ae/Text/NSPlist/Parsec.hs#L70-L75
For example, trying to parse a backslash in a quoted string:
fails:
This is because it’s trying to interpret Haskell specific escape codes, escape characters, and numeric escapes:
See §2.6 for more info. https://www.haskell.org/onlinereport/lexemes.html
One solution might be to forgo any unescaping and just return the raw string. Another solution might be to make the parsing and printing understand NeXTStep style escaping.
Background
I‘m looking into building a tool (https://github.com/gnarf/osx-compose-key/issues/17) that parses
DefaultKeyBinding.dict
files, which uses backslashes/escaping heavily, as a learning exercise.