Leon Rosenberg wrote:
Hi,
I have a small encoding problem, which drives me crazy...
Our complete site is in ISO-8859-1 (which is java-default, as I understand

Java uses the system default, which is locale dependant, so you can't just assume Latin 1.


it). I mean, the charset of the page is ISO, and meta-tags in HTML are
telling the browser that the page is ISO too.

Make sure that you have the content type declared in your JSPs using an @page directive to be certain everything is sent using the encoding you expect. I'm not sure that meta tags are enough if the content type isn't set right.


Now the problem, that I have, is that I have to transmit some XML data to
another system (payment provider) which expects it in UTF-8. The problem is that customer name can contain Umlauts (german characters:
äöü), and they come truncated on the other side:
Like I'm sending "Ümlaut" and the other side gets �mlaut. I tried each conversion method I could think of sofar:
reinitializing the String as new String with reencoding: name = new
String(name.getBytes("ISO-8859-1"), "UTF-8") (in all combinations)
Using URLDecoder to decode parameters.
Using charsetencoded Writer (OutputStreamWriter writer = new
OutputStreamWriter(outStream, "UTF-8")).
and so on... Can anyone give me a hint?

Once you have a String object, it's already been re-encoded. You need to make sure that when you set 'name' initially you're taking care of the encoding.


    request.setCharacterEncoding("ISO-8859-1");
    String name = request.getParameter("name");

Then make sure to specify UTF-8 encoding when you write it out.

L.

This problem is slowly driving me crazy.... regards
and thanx in advance
Leon




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to