mockersf / hocon.rs

Parse HOCON configuration files in Rust
MIT License
78 stars 16 forks source link

Auto-unescape strings and handle unicode escape sequences in strings #53

Closed null-dev closed 2 years ago

null-dev commented 3 years ago

Currently the parser doesn't auto-unescape strings (e.g. "\\" gets parsed to: r#"\\"# when it should actually be parsed to: r#"\"#).

Same regarding unicode escape sequences, e.g.: "\uD834".

There's an example here that is able to properly validate unicode escape sequences: https://github.com/changhe3/nom-json-parser/blob/cce34f560f394cdf1601ab9c5c2fd012eb405084/src/parser.rs#L132 but it doesn't do any auto-unescaping.

null-dev commented 3 years ago

Nevermind, the example I linked actually does unescaping: https://github.com/changhe3/nom-json-parser/blob/cce34f560f394cdf1601ab9c5c2fd012eb405084/src/utils.rs#L73

So it should be possible to drop that into this project.