UTF Encoding for Chinese CharactersJava

Viewed 23372

I am receiving a String via an object from an axis webservice. Because I'm not getting the string I expected, I did a check by converting the string into bytes and I get C3A4C2 BDC2A0 C3A5C2 A5C2BD C3A5C2 90C297 in hexa, when I'm expecting E4BDA0 E5A5BD E59097 which is actually 你好吗 in UTF-8.

Any ideas what might be causing 你好吗 to become C3A4C2 BDC2A0 C3A5C2 A5C2BD C3A5C2 90C297? I did a Google search but all I got was a chinese website describing a problem that happens in python. Any insights will be great, thanks!

2 Answers
public class Encoder{
    public static void main(String[] args) throws Exception {
     String requestString="你好";
     String ISO = new String(requestString.getBytes("gb2312"), "ISO8859-1");
     String plaintxt = new String(ISO.getBytes("ISO8859-1"), "gb2312");
     plaintxt.getBytes("UTF-8");
    }
}
Related