Fix symbol escaping during conversion to text

This commit is contained in:
Emery Hemingway 2022-12-07 22:05:24 -06:00
parent 3dd112879d
commit cc0703c343
1 changed files with 6 additions and 6 deletions

View File

@ -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, "\\|")