From cc0703c343a8ce298c633b90b80cd069ffa12d24 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Wed, 7 Dec 2022 22:05:24 -0600 Subject: [PATCH] Fix symbol escaping during conversion to text --- src/preserves.nim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/preserves.nim b/src/preserves.nim index 0d69621..a7db9ab 100644 --- a/src/preserves.nim +++ b/src/preserves.nim @@ -1315,7 +1315,7 @@ proc writeText*[E](stream: Stream; pr: Preserve[E]) = write(stream, '"') of pkSymbol: let sym = pr.symbol.string - if sym.len > 0 and sym.allIt(char(it) in {'0'..'9', 'A'..'z'}) and sym[0] notin {'0'..'9'}: + if sym.len > 0 and sym[0] in {'A'..'z'} and not sym.anyIt(char(it) in { '\x00'..'\x19', '"', '\\', '|' }): write(stream, sym) else: write(stream, '|') @@ -1325,15 +1325,15 @@ proc writeText*[E](stream: Stream; pr: Preserve[E]) = write(stream, "\\\\") of '/': write(stream, "\\/") - of '\x62': + of '\x08': write(stream, "\\b") - of '\x66': + of '\x0c': write(stream, "\\f") - of '\x6e': + of '\x0a': write(stream, "\\n") - of '\x72': + of '\x0d': write(stream, "\\r") - of '\x74': + of '\x09': write(stream, "\\t") of '|': write(stream, "\\|")