Re: Charset encoding issue

2003-09-06 Thread Anton Tagunov
Hello Lima!

lccb> I have a jsp page with some form fields. I don't know how is the right way
lccb> to set the charset (because we're using portuguese characters). This is
lccb> the only configuration that have worked for me :

lccb> <%@ page contentType="html/text; charset=UTF-8"%>

To the best of my knowledge w3c standards do not prescribe
the browser what charset to encode form fields with.
In practice however this is generally the same charset
that the page containing form is in. So yes, if you want
the form data to be encoded with charset XXX you need your
page to have content type with charset XXX. And this is
what this <[EMAIL PROTECTED]> directive is doing. (In a servlet you
would do response.setContentType()).

I have written an elaborate essay on this, it should
still be available at http://tagunov.tripod.com

lccb> 
As far as I know enctype here is not required.

lccb> Is it right ? Is there other way ?
Hope this mail and my old essay have answered at least
part of your questions.

WBR, Anton


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



Re: Charset encoding issue

2003-09-06 Thread lima
But why when i modify or remove the enctype from  tag, the browser
seems to "forget" the correct charset of these form fields ?

Thanks.

> Hello Lima!
>
> lccb> I have a jsp page with some form fields. I don't know how is the
> right way
> lccb> to set the charset (because we're using portuguese characters). This
> is
> lccb> the only configuration that have worked for me :
>
> lccb> <%@ page contentType="html/text; charset=UTF-8"%>
>
> To the best of my knowledge w3c standards do not prescribe
> the browser what charset to encode form fields with.
> In practice however this is generally the same charset
> that the page containing form is in. So yes, if you want
> the form data to be encoded with charset XXX you need your
> page to have content type with charset XXX. And this is
> what this <[EMAIL PROTECTED]> directive is doing. (In a servlet you
> would do response.setContentType()).
>
> I have written an elaborate essay on this, it should
> still be available at http://tagunov.tripod.com
>
> lccb> 
> As far as I know enctype here is not required.
>
> lccb> Is it right ? Is there other way ?
> Hope this mail and my old essay have answered at least
> part of your questions.
>
> WBR, Anton
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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



RE: Charset encoding issue

2003-09-07 Thread Francisco Vides Fernandez

I've recently have a similar problem with spanish language. What OS
are you running Tomcat on? What are your LOCALE settings?


> "lima" == lima  <[EMAIL PROTECTED]> writes:

 lima> Hi, guys. How are you ?  I have a jsp page with some form
 lima> fields. I don't know how is the right way to set the charset
 lima> (because we're using portuguese characters). This is the only
 lima> configuration that have worked for me :

 lima> <%@ page contentType="html/text; charset=UTF-8"%>

 lima> (...)

 lima> 


 lima> Is it right ? Is there other way ?



 lima> Thanks in advance.



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

-- 
+-
| Francisco Vides Fernández <[EMAIL PROTECTED]>
| Director técnico.
| Teléfono fijo:   952 60 29 59
| Teléfono móvil:  661 67 32 73
| Fax: 952 60 29 59
| Dédalo Ingenieros http://www.dedaloingenieros.com/
| PGP: http://pgp.rediris.es:11371/pks/lookup?op=index&search=0x5AAE6285
+--


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



RE: Charset encoding issue (again :-))

2003-10-09 Thread Edson Alves Pereira
The best way to solve that is to set -Dfile.encoding=ISO-8859-1 in
JAVA_OPTS, with this you ensure that your JVM is using the encoding that you
want.

> --
> De:   Daniel H A Lima[SMTP:[EMAIL PROTECTED]
> Responder:Tomcat Users List
> Enviada:  quinta-feira, 9 de outubro de 2003 10:45
> Para: Tomcat Users List
> Assunto:  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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


Re: Charset encoding issue (again :-))

2003-10-09 Thread Daniel H A Lima
But with this approach, all web apps running under the same JVM will use 
this encoding. We want to avoid this...

Edson Alves Pereira wrote:

The best way to solve that is to set -Dfile.encoding=ISO-8859-1 in
JAVA_OPTS, with this you ensure that your JVM is using the encoding that you
want.
 



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


RE: Charset encoding issue (again :-))

2003-10-09 Thread Edson Alves Pereira
Then, you could create a class that would convert strings from some
encoding that you don´t known and transform to UTF-8 and that class load its
configuration from a local .properties file to make it flexible, for
example:

public String getParameter( String stName_ )
{
//This will change the native encoding to you favorite one:
byte[ ]b = request.getParameter( "MyParam" ).getBytes(
"UTF-8" );

return new String( b ); //To use default encoding:
return new String( b, "UTF-8" );//Some different:
}


> --
> De:   Daniel H A Lima[SMTP:[EMAIL PROTECTED]
> Responder:Tomcat Users List
> Enviada:  quinta-feira, 9 de outubro de 2003 11:11
> Para:     Tomcat Users List
> Assunto:  Re: Charset encoding issue (again :-))
> 
> But with this approach, all web apps running under the same JVM will use 
> this encoding. We want to avoid this...
> 
> Edson Alves Pereira wrote:
> 
> > The best way to solve that is to set -Dfile.encoding=ISO-8859-1 in
> >JAVA_OPTS, with this you ensure that your JVM is using the encoding that
> you
> >want.
> >
> >  
> >
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


Re: Charset encoding issue (again :-))

2003-10-09 Thread Daniel H A Lima
But to do

byte[ ]b = request.getParameter( "MyParam" ).getBytes(
"UTF-8" );
you must know the charset encoding of the form paramaters (utf-8 in this 
case) which leads us to original question.

Edson Alves Pereira wrote:

Then, you could create a class that would convert strings from some
encoding that you don´t known and transform to UTF-8 and that class load its
configuration from a local .properties file to make it flexible, for
example:
public String getParameter( String stName_ )
{
//This will change the native encoding to you favorite one:
byte[ ]b = request.getParameter( "MyParam" ).getBytes(
"UTF-8" );
return new String( b ); //To use default encoding:
return new String( b, "UTF-8" );  //Some different:
}
 

--
De: Daniel H A Lima[SMTP:[EMAIL PROTECTED]
Responder:  Tomcat Users List
Enviada:quinta-feira, 9 de outubro de 2003 11:11
Para:   Tomcat Users List
Assunto:Re: Charset encoding issue (again :-))
But with this approach, all web apps running under the same JVM will use 
this encoding. We want to avoid this...

Edson Alves Pereira wrote:

   

	The best way to solve that is to set -Dfile.encoding=ISO-8859-1 in
JAVA_OPTS, with this you ensure that your JVM is using the encoding that
 

you
   

want.

 



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