Reputation: 75545
In C, if I put a literal string like "Hello World \n\t\x90\x53"
into my code, the compiler will parse the escape sequences into the correct bytes and leave the rest of characters alone.
If the above string is instead supplied by the user, either on the command line or in a file, is there a way to invoke the compiler's functionality to get the same literal bytes into a char[]
?
Obviously I could manually implement the functionality by hardcoding the escape sequences, but I would prefer not to do that if I can just invoke some compiler library instead.
Upvotes: 4
Views: 115
Reputation: 399753
No, there's no standard function to do that.
A suggestion for a non-standard library solution is to use glib's g_strcompress()
function.
Upvotes: 5