I have a string containing backslashes:
"{ \time 4/4 \key c \major d'4 }"
When I try to pass it in a nodejs child_process or just to console.log it, the backslashes are removed:
console.log("{ \time 4/4 \key c \major d'4 }");
// "{ ime 4/4 key c major d'4 }"
I have tried all things I cound find, such as .replace(/\\/g, '\\')
or JSON.stringify
, but nothing seems to work.
The string is constructed dynamically so I can't escape it manually.
Any ideas?
Update after comments:
I am getting this string from a library written in python (python-mingus) using node-python.
As I understand from the answers and the comments, there is no way to parse the string correctly without altering either the library or the wrapper...
Thank you all.