Currently, we are using StringEscapeUtils.escapeEcmaScript
to escape any quotes and tabs etc, it works for English but when it comes to Japanese it encodes all the Japanese characters into unicode, need suggestions on how to maintain Japanese characters while escaping all the special characters(quotes, tabs etc).
example:
System.out.println(StringEscapeUtils.escapeEcmaScript("Price must be between 1 and 3"));
System.out.println(StringEscapeUtils.escapeEcmaScript("で本を販売して 70% のロイヤリティを得るに"));
System.out.println(StringEscapeUtils.escapeEcmaScript("Der Preis muss zwischen angewendet werden kann."));
output:
Price must be between 1 and 3
\u3067\u672C\u3092\u8CA9\u58F2\u3057\u3066 70% \u306E\u30ED\u30A4\u30E4\u30EA\u30C6\u30A3\u3092\u5F97\u308B\u306B
Der Preis muss zwischen angewendet werden kann.
looks like it only fails in Japanese