What is the right way to escape control characters in Erlang?
I do:
[EscapedString] = io_lib:format("~p", [Str]).
It works as I expect for \t
and \n
characters:
io_lib:format("~p", ["str\ning"]).
["\"str\\ning\""]
But for \a
:
io_lib:format("~p", ["str\aing"]).
["\"straing\""]
and
io_lib:format("~p", ["a\x07"]).
[[91,["97",44,"7"],93]]
I need to get "\"str\\aing\""
string and in file it should look like "str\aing"
.
Thank you for your help :)