I need to escape entire javascript code block using escape() compatible function via PHP, and then put resulting JavaScript code back into a code construct like this:
document.write(unescape(ESCAPED_JS));
I’m not trying to increase security by doing this, protect code, or anything like that. Just to make it a bit harder to glance over a code and see what it does.
Does anyone have a working solution for this, or idea how to do it? The only reference I found about it is on this page, but it only deals with unescaping JS-escaped string using PHP, but by taking special care of UTF-8 characters (which I also need to consider).
escapeis not a standard function. Better useencodeURIComponentor JSON instead.