Surya G Surya G - 3 years ago 109
HTTP Question

Encoding/Content-Type issue with Danish letters "æ"

I have an issue with encoding the Danish letters from the HTTP REST response.

When I call the REST service I am getting "bev�ge" which must be "bevæge", The Chrome browser encodes it and gives me the expected letters as "bevæge", but when I read the response from Java API's I am getting "bev�ge", can sombody help me to solve this issue, will be greatful,

Thanks in advance

Answer Source

You seem to have a mismatch with your encoding

Consider

    String str = "bevæge";

    byte[] b = str.getBytes();

    try {
        System.out.println(new String (b, "US-ASCII"));
        System.out.println(new String (b, "UTF8"));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

The output would be

bev��ge
bevæge
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download