From the 5.2 manual:
On 21 Feb 2013, at 12:48, Marc Balmer wrote:
> How should "%q" format it's parameter?
"The q option formats a string between double quotes, using escape sequences when necessary to ensure that it can safely be read back by the Lua interpreter."
I'm not saying it's really difficult to do, I just thought there might be some code out there already, as if I do it myself, it's the kind of thing where it's really easy to write a buggy implementation.