I’m searching for a library (Apache / BSD / EPL licensed) to convert native text to ASCII using \u for characters not available in ASCII (basically what java.util.Properties does).
I had a look and there don’t seem to be any readily available libraries. I found:
- JDK, tools.jar, native2ascii
- Properties.saveConvert() (private method)
- http://www.koders.com/java/fidD26ED81BEBE41932C405904AD53AEE8459BB8509.aspx (GPL)
Is anyone aware of a library under the above stated licenses?
You can do this with an CharsetEncoder. You have to read the ‘native’ Text with the correct encoding to unicode. Than you can use an ‘US-ASCII’-encoder to detect, which characters are to be translated into unicode escapes.
Additionally org.apache.commons:commons-lang contains StringEscapeUtils.escapeJava() which can escape and unescape native strings.