kowainik / tomland

🏝 Bidirectional TOML serialization
https://kowainik.github.io/posts/2019-01-14-tomland
Mozilla Public License 2.0
121 stars 39 forks source link

Unicode escape #354

Closed dariodsa closed 3 years ago

dariodsa commented 3 years ago

Issue #334

File changed

Function in Printer.hs was changed in order to allow escaping unicode characters. Firstly escaping unicode characters are performed before calling function show which will escape others like \n. I implemented tests but they are not functional. The reason is that because currently char č is parsed into \U0000010d and it can only be unparsed into \U0000010d. That is the reason why those tests will fail (starting char is not equal to end). I am still wondering should I add that tests with different printing without \u or \U or this is good enough.

*Toml> Toml.decode (Toml.text "a") $ Toml.encode (Toml.text "a") "č"
Right "\\U0000010d"
*Toml> Toml.decode (Toml.text "a") $ Toml.encode (Toml.text "a") "\\u010d"
Right "\\u010d"
chshersh commented 3 years ago

Hi @dariodsa! Thanks for working on this 🤗 It's a bit busy time, but we'll try to find time to review the PR.