CString package:BNFC

A function that renders a c-like string with escaped characters. Note that although it's called cstring, this can be used with most (all) backend as they seem to mostly share escaping conventions. The c in the name is barely an homage for C being the oldest language in the lot.
>>> cstring "foobar"
"foobar"
>>> cstring "foobar\""
"foobar\""