Open kukimik opened 1 year ago
Also, I didn't measure the performance. I'm not sure how Text
concatenations are implemented, i.e. how many times the whole thing gets copied. Probably this can get meaningful when dealing with long strings. As a newbie I'm not really sure if it's better to use a Builder
here, or with this amount of concatenation it is not worth it.
This should close #408. The extra
\
was introduced byshow
. Along the way some other escaping issues introduced by theshow
"shortcut" are fixed (like improper escaping of control characters like\DEL
,\NUL
). Haskell escaping is not TOML escaping (the latter is much simpler, e.g. there is no need for a\&
).Caveats:
TOML allows unescaped Unicode characters, with only a few exceptions:
Therefore escaping everything outside ASCII is a waste of space of and hurts readability. However, I wanted to keep the fix backwards compatible. Moreover, Unicode is difficult, and it is not trivial to decide which characters "should" be escaped (probably the unprintable ones? but what else?). I think the decision what to escape should be left to the user of the library, via a new
PrinterOption
. I think I can implement this in a separate PR (together with fixing the tests) if I find the time. What is your opinion?\UXXXXXXXX
. However, the short form\uXXXX
is also permitted, and I think it is preferable whenever it can be applied, because it saves a few bytes. I kept the long form to make things backward compatible. Introducing the short form should be trivial change in the code and I am tempted to make it, but I want to know your opinion.