geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From donH <justj...@gmail.com>
Subject Re: UTF-8 request strings corrupted
Date Mon, 09 Jul 2007 13:12:56 GMT


Lukasz,

I think a lot of times that the encoding is lost or has a bad translation
because of the platform default encoding. For example if you create a string
on windows the default encoding is cp-1252 and then try and apply UFT-8 as
in new String("string", "UTF-8") you will lose the encoding because of the
machines default, when you are pulling bytes off of a stream or setting them
on the request you will have to explicitly set UTF-8 on all strings.

As far as sys.out this will only work if you can a console that supports
UTF-8, if you are in a flavor of linux then your in luck.

I think you may also be able to use a jsp, get the outputstream and use the
write(bytes) method. Maybe something like this.

Map<String,String[]> temp = (Map<String,
String[]>)request.getParameterMap();
for (String s: temp.keySet()) {
      // output to the console
      // this will print every single Polish character as double '?'
      String s =   new String(temp.get(s)[0], "UTF-8");
      os.write( s.getBytes("UTF-8"));

}







Xh wrote:
> 
> Hi All!
> 
> I have a problem with UTF-8 web pages encoding and Polish language.
> 
> Pages are generated from XML files with XSLT. All Polish characters are
> properly displayed.
> Everything is OK.
> 
> Response is sent as:
> 
> Server: Apache-Coyote/1.1
> Set-Cookie: JSESSIONID=DCDE41C9E12D69A15B261649CF15DF8E; Path=/DataWeaver
> Content-Type: text/html;charset=UTF-8
> ...
> 
> also, the generated XHTML resposne's <header> element consists:
> 
> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
> <meta content="pl" http-equiv="Content-Language"/>
> 
> but...
> 
> when I fill Polish characters in web form and submit it, all Polish
> characters are corrupted...
> 
> for example, inserted records in database are displayed as strange strings
> 
> furthermore, when I extract parameters in this way:
> 
> Map<String,String[]> temp = (Map<String,
> String[]>)request.getParameterMap();
> for (String s: temp.keySet()) {
>       // output to the console
>       // this will print every single Polish character as double '?'
>       System.out.println(s + ": " + temp.get(s)[0]);
> }
> 
> any idea how to extract UTF-8 encoded strings from request?
> 
> thanks in advance
> best regards
> Lukasz
> 
> 
> 
> 
> 		
> ___________________________________________________________ 
> To help you stay safe and secure online, we've developed the all new
> Yahoo! Security Centre. http://uk.security.yahoo.com
> 

-- 
View this message in context: http://www.nabble.com/UTF-8-request-strings-corrupted-tf4048046s134.html#a11501476
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Mime
View raw message