tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel H A Lima <l...@cit.com.br>
Subject Charset encoding issue (again :-))
Date Thu, 09 Oct 2003 13:45:54 GMT
    Hi, everybody. I've some doubts about html form charset encoding. I 
will be glad if someone could answer questions above.

1 ) We have jsp files with directive <%@ page language="java" 
pageEncoding="utf-8" contentType="text/html;charset=utf-8" %>
and some classes with the following working code :

    if ( request.getEncoding() == null ) {
          String s = request.getParameter( "some_param" );
          byte [] b = s.getBytes( "iso-8859-1");
          s = new String( b, "utf-8" );
    }

  a) Will it work for any charset encoding ? If i replace "utf-8" for 
"windows-1251" this code will still work ?
  b) Is there another clean way to use "utf-8" in my jsp pages ?
   
   I've read the document in http://tagunov.tripod.com/i18n/i18n.html 
but i'm not sure if i could understand it.   :-(

2 ) When i use request.setEncoding( "windows-1251") and 
request.getParameter( "some_param" ), which one of these sentences will 
be true ?

    a) request.getParameter() will do

        byte [] b = s.getBytes( "iso-8859-1");
        return new String( b, "windows-1251" );

    b) request.getParameter() will do
 
        byte [] b = s.getBytes( "windows-1251" );
        return new String( b );       

    c) request.getParameter() will do
 
        byte [] b = s.getBytes( "windows-1251" );
        return new String( b, "windows-1251" );       

    d) request.getParameter() will do

        byte [] b = s.getBytes();
        return new String( b, "windows-1251" );


                    Thanks in advance !!!!



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message