0

how could I convert a text escaped with StringEscpeUtils.escapeJavascript back to the original text in java? I have converted a russian text with escapeJavascript and the result is: \u041F\u043E\u0440\u043E\u0434\u044B, but backwards it is not working.

Thank you !

McDowell
  • 107,573
  • 31
  • 204
  • 267
Iulia Muntianu
  • 145
  • 1
  • 14

2 Answers2

2

Try the unescapeJavascript method.

Michael
  • 57,169
  • 9
  • 80
  • 125
0

You can try native2ascii, a command line tool in the bin directory of java. You need the original encoding.

The following alternatives try default encoding (your OS, System.getProperty("file.encoding")), Cyrillic, and Russian.

native2ascii -reverse input.txt output.txt
native2ascii -reverse -encoding windows-1251 input.txt output.txt
native2ascii -reverse -encoding KOI8-R input.txt output.txt

Naturally in java you would simply print/write the string.Ä

Joop Eggen
  • 107,315
  • 7
  • 83
  • 138