Re: [Simpleweb-Support] What encoding of String that Request.getParameter() return?
Brought to you by:
niallg
From: Niall G. <gal...@ya...> - 2005-12-08 01:27:37
|
Hi, All input, be it a URI, URI parameters, or POSTed parameters are (by specification) meant to be ISO-8859-1. UTF is supported in the % HEX HEX escaping done by the client. You should have to do no character encoding anywhere in Simple. All characters are converted correctly, or should be. So, as Martin said, inString.getBytes("ISO-8859-1") will result in a conversion from Java UCS-2 (which is 16-bit) to ISO-8859-1 which is (8-bit). Resulting in a mangled string. Niall --- Martin Norrsken <mar...@gm...> wrote: > on 12/7/05, Carfield Yim <car...@gm...> wrote: > > > > > > I dont quite understand this? Java Strings are > charset-neutral as far > > > as i know (and always stored internally as > UTF-16), so there is no > > > need to "convert" a string to anything as the > string does not retain > > > charset information. The only conversion is dont > at Input/Output > > > stream level or when encoding to other formats > (such as URLEncoder). > > > > > In some servlet container (tomcat and jetty as I > know) If you submit > > multibytes character in HTML form, it will > incorrectly assume that it > > is "ISO-8859-1", and return the incorrect encoded > string at > > request.getparameter() method. In order to get > back the correct > > string, I need to do the above. > > I see how it works now. Anyway might it have > something to do with the > fact that SimpleWeb actually tries to decode query > parameters > submitted in UTF-8 as i see the ParameterParser and > URIParse classes > does? I would think this causes a problem if the > input is already in > UTF and when you do inString.getBytes("ISO-8859-1") > you get the ISO > representations of characters (for example you get > the string > "Björnbär" which is already correct), which will > mess up when trying > to encode these into UTF-8 again (which will result > in "Bj?rnb?"). > > /Martin > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do > you grep through log files > for problems? Stop! Download the new AJAX search > engine that makes > searching your log files as easy as surfing the > web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_idv37&alloc_id865&op=click > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > Niall Gallagher __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |