Pregunta

i'm writing a custom compiler pass for Closure that switches javascript literal strings to hex. So "a" becomes "\x61"

but the code:

node.setString("\\x61");

results in javascript like this:

"\\x61"

instead of:

"\x61"

Of course, if I only use one slash in my java code, then it won't compile. The same is true with \n. It seems that somewhere behind the scenes, Closure / Rhino is automatically escaping the strings. But I can't find where. How can I write a string with special chars?

¿Fue útil?

Solución

I believe this would have to be done during output (code printing). Internally the string will be represented in it's unescaped form. Take a look at the Code Generator.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top