I have a string with UTF8 characters in it and I’m using StringEntity to put it into a HttpEntityEnclosingRequestBase and send it to a server.
My problem is that the UTF8 characters are coded as \xF2 and the server would like \u00f2. How can I fix this? Or how can I easily convert an UTF-8 string to a string where I have \u00f2 like substrings instead of the UTF8 chars?
Solution:
In the end, the solution was:
StringEntity(string, “UTF-8”));
Thanks in advance, David
You can convert between Java’s internal character encoding (UTF-16) and UTF-8 byte sequences in a variety of ways. The simplest is:
There are also stream-oriented classes that can translate between byte streams and character streams using an encoding. See the
java.iopackage.