Hi!
I know it is possible to create raw strings with r or R like:
let msg = r"tHellon" # raw string
But if I have a string that was not created as raw, is it possible to make it raw?
let msg = "tHellon" # string
let raw_msg = MakeStringRaw(msg) # my wish
It is possible? I looked in the documentation and did not find anything relating.
Thanks,
Marcelo Módolo
Raw strings are just the same as a normal string. Only difference is how they are created. With normal strings it will escape things like \\t to be a tab, but with raw string literals it will be the two characters \\ and t. But I assume what you want is to replace all the escape characters by their escape sequence in which case you can do something like this:
let msg = "\tHello world\n"
var escaped = ""
for c in msg:
escaped.addEscapedChar(c)
echo escaped
Thanks!
This is exactly what I was looking for! I started programming a little while ago with nim!
Regards, Marcelo Módolo