I am setting the environment for a program I will be launching using QProcess. One of the environment variables I need to set MAY contain spaces, slashes, and quotes. What is the right way to handle this?
I've tried escaping quotes, and adding a \" to either end of the string but my environment variable is always blank. Can someone share a code sample of how to handle this?
I'm thinking about this:
a = "\""+a.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\""))+"\"";
but after numerous attempts I thought I would ask for help too.
For example, if a is:
A" \ / '
and I try to set an environment variable through
environment << "a=\""+a+"\""
and pass environment as the first parameters for a qprocess run, then the variable is NOT set when the qprocess starts, due to the fact that the environment ignores the malformed string.