Looking at the implementation of strutils.unescape, it seems to only interpret
the xHH syntax that escape outputs. Of course, the compiler proper is often
changing those raw/quoted string forms into special characters. So, maybe there
is some other approach/trick that could work..sort of like an
@Krux02, maybe this is a bug, you could post an issue on GitHub.
no, I am asking for the inverse of that function. There is unescape, but it
doesn't do what I want to do:
import strutils
let str = r"\n\r"
echo str
assert unescape(str, "", "") == "\n\r"
Perhaps you want strutils.escape? I.e.:
import strutils
echo escape("\n\t")
Output is "\x0A\x09"
Its output is designed to be as portable an 'input' to
de-escapers/escape-interpreters as possible. So you will see things like \x0A
and \x09 instead of the \n \t because the
I have a macro with a string argument. The string is partially preserved, but
all n from the string are now litterally n and t. so how do I unescape
thesevalues to create a string object out of them? All my ideas right now feel
like a lot of work with some uncertenty if I did everything correct,