You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Daniel H A Lima <li...@cit.com.br> on 2003/10/09 15:45:54 UTC
Charset encoding issue (again :-))
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