Fix symbol escaping during conversion to text
This commit is contained in:
parent
3dd112879d
commit
cc0703c343
|
@ -1315,7 +1315,7 @@ proc writeText*[E](stream: Stream; pr: Preserve[E]) =
|
||||||
write(stream, '"')
|
write(stream, '"')
|
||||||
of pkSymbol:
|
of pkSymbol:
|
||||||
let sym = pr.symbol.string
|
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)
|
write(stream, sym)
|
||||||
else:
|
else:
|
||||||
write(stream, '|')
|
write(stream, '|')
|
||||||
|
@ -1325,15 +1325,15 @@ proc writeText*[E](stream: Stream; pr: Preserve[E]) =
|
||||||
write(stream, "\\\\")
|
write(stream, "\\\\")
|
||||||
of '/':
|
of '/':
|
||||||
write(stream, "\\/")
|
write(stream, "\\/")
|
||||||
of '\x62':
|
of '\x08':
|
||||||
write(stream, "\\b")
|
write(stream, "\\b")
|
||||||
of '\x66':
|
of '\x0c':
|
||||||
write(stream, "\\f")
|
write(stream, "\\f")
|
||||||
of '\x6e':
|
of '\x0a':
|
||||||
write(stream, "\\n")
|
write(stream, "\\n")
|
||||||
of '\x72':
|
of '\x0d':
|
||||||
write(stream, "\\r")
|
write(stream, "\\r")
|
||||||
of '\x74':
|
of '\x09':
|
||||||
write(stream, "\\t")
|
write(stream, "\\t")
|
||||||
of '|':
|
of '|':
|
||||||
write(stream, "\\|")
|
write(stream, "\\|")
|
||||||
|
|
Loading…
Reference in New Issue