And just follow up, since guyd has module on git hub that does this, the links for it (and the compiled download) are on the "Idea"/Enhancement request page :
The enhancement still has only 4 votes, it would be nice to see it get more support, since this sort of escaping is essential for secure coding and be nice it have it in the core product - rather than doing regex pattern matches.
So please vote for it :-)
Cheers - Mark