1 Reply Latest reply on Mar 7, 2007 5:51 PM by raist_majere

    forms and input elements UTF-8 encoding problem

    xhemjl

      Hi all,

      I have my page in UTF-8, all polish characters are displayed correctly,
      the response headers are:

      Server: Apache-Coyote/1.1
      X-Powered-By: Servlet 2.4; JBoss-4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)/Tomcat-5.5
      Content-Type: text/html;charset=UTF-8


      I have form with input text field when I enter, for example my polish
      first name - ?ukasz the "?" is represented as '??'

      // debug inside my doPost()
      for (String key: parameters.keySet()) {
       System.out.println(key + " = " + parameters.get(key)[0]);
      }


      the following code with String(bytes, encoding) also does not work:

      for (String key: parameters.keySet()) {
       try {
       System.out.println(key + " = " + new String(parameters.get(key)[0].getBytes(), "UTF-8"));
       } catch (UnsupportedEncodingException e) {
       throw new RuntimeException(e);
       }
      }


      how can I decode parameters and represent them in UTF-8?

      thanks in advance for any hints
      best regards ?ukasz

        • 1. Re: forms and input elements UTF-8 encoding problem
          raist_majere

          I think your problem is same I had once... As long as you try to write parameters to System.out, when they get displayed on the console they don't show correctly due to DOS command line only displays ASCII chars (or another encoding that cannot display non-american chars). Try writing them to a log file (for example) or to an HTML page with the correct encoding and I assume they will show in the proper way.