How to convert JavaScript code into one big Java string

So I have 1000 lines of javascript. I need to turn it into a Java string so that I can output (via System.out.printlnor something else).

I am looking for an online tool to avoid all quotes ... something that focuses on my specific need would be nice since I don't want to change other special characters. Lines like:

var rgx = /(\d+)(\d{3})/;

must remain intact.

The situation requires JavaScript to be placed in a string, so please do not bypass workarounds.

+3
source share
4 answers

, Crockford quote(). JavaScript.

: , ascii.

Edit2: : , JavaScript , ...

Edit3: - .html script:

<script src="quote.js"></script>
<script>
// this is the JavaScript to be converted:
var foo = 'bar';
var spam = 'eggs';

function fancyFunction() {
    return 'cool';
}
</script>
<pre><script>
document.writeln(quote(
    document.getElementsByTagName('script')[1].firstChild.nodeValue, true));
</script></pre>
+5

jsmin, Javascript (), . / .

0

, , , , javascript. , , , :

Notepad ++:

  • Shift + Tab,

  • Do View →

  • LF char ,
  • CR char

  • Highlight "(quote character) and do" Replace All With "(escaped quote) ... just type the quote character in the" Replace "prompt to capture some quotes for some reason.

  • Now you have 1 extremely long line ... I had to split 1 line into lines of about 2000 characters ... A crazy long line killed IE and / or broke the Java limit line.

0
source

All Articles