i18n vs WebSphere; processing forms in diff. character encodings

Discussions

Web tier: servlets, JSP, Web frameworks: i18n vs WebSphere; processing forms in diff. character encodings

  1. We are currently developing a web application that is accessible from a number of countries. The application comprises a number of forms and work fine, except when they are used from some eastern european countries, that uses a different character set.

    The requests we receive are encoded as UTF-8 in these cases. Users from other countries use other encodings and they work fine. If the english language is added to the client's browser, it also works fine. But this is not considered to be an acceptable solution.

    When the request is encoded as UTF-8, calling request.getParameter() returns illegal values. The result is trimmed at the first non regular character.

    We tried the following:
    - setting accept-charsets on the table;
    - String val = new String ( request.getParameter("..").getBytes( "ISO8859_1"), `actual encoding used`)

    But neither of these approaches works.

    The application is hosted on WebSphere 3.5 (on AIX) and seems to have worked fine under the same circumstances on oracle.

    Has anyone dealt with this before and can you supply us suggestions or even better, a working solution?

    Thanks in advance,

    Patrick
  2. Why allow the client to use anything but UTF-8 in the first place? All modern browsers support it, including in Central Europe.
  3. String inputEncoding=request.getCharacterEncoding();

    String ans=new String (request.getParameter("your_param").getBytes(inputEncoding==null?"ISO-8859-1":inputEncoding),"your_target_encoding");


    Best regards,
      Dmitry Namiot
      Coldbeans