Return-Path: Delivered-To: apmail-sling-users-archive@minotaur.apache.org Received: (qmail 3858 invoked from network); 28 Feb 2011 10:09:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Feb 2011 10:09:23 -0000 Received: (qmail 9368 invoked by uid 500); 28 Feb 2011 10:09:23 -0000 Delivered-To: apmail-sling-users-archive@sling.apache.org Received: (qmail 9177 invoked by uid 500); 28 Feb 2011 10:09:20 -0000 Mailing-List: contact users-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@sling.apache.org Delivered-To: mailing list users@sling.apache.org Received: (qmail 9169 invoked by uid 99); 28 Feb 2011 10:09:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Feb 2011 10:09:18 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of fmeschbe@adobe.com designates 64.18.1.25 as permitted sender) Received: from [64.18.1.25] (HELO exprod6og110.obsmtp.com) (64.18.1.25) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Feb 2011 10:09:11 +0000 Received: from source ([193.104.215.16]) by exprod6ob110.postini.com ([64.18.5.12]) with SMTP ID DSNKTWt0MSOagXKkgrsqCsKFJ35QWALPea2H@postini.com; Mon, 28 Feb 2011 02:08:50 PST Received: from inner-relay-4.eur.adobe.com (inner-relay-4b [10.128.4.237]) by outbound-smtp-2.corp.adobe.com (8.12.10/8.12.10) with ESMTP id p1SA8i1L011084 for ; Mon, 28 Feb 2011 02:08:45 -0800 (PST) Received: from nacas03.corp.adobe.com (nacas03.corp.adobe.com [10.8.189.121]) by inner-relay-4.eur.adobe.com (8.12.10/8.12.9) with ESMTP id p1SA8c1S006276 for ; Mon, 28 Feb 2011 02:08:42 -0800 (PST) Received: from eurcas01.eur.adobe.com (10.128.4.27) by nacas03.corp.adobe.com (10.8.189.121) with Microsoft SMTP Server (TLS) id 8.3.137.0; Mon, 28 Feb 2011 02:08:38 -0800 Received: from [10.131.197.85] (10.131.197.85) by eurcas01.eur.adobe.com (10.128.4.111) with Microsoft SMTP Server id 8.3.137.0; Mon, 28 Feb 2011 10:08:36 +0000 Subject: Re: request.getCharacterEncoding() always returns ISO-8859-1 From: Felix Meschberger To: "users@sling.apache.org" In-Reply-To: <1298650365.32593.1364.camel@meschbix> References: <1298650365.32593.1364.camel@meschbix> Content-Type: text/plain; charset="UTF-8" Date: Mon, 28 Feb 2011 11:08:35 +0100 Message-ID: <1298887715.2413.4.camel@meschbix> MIME-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi, I have implemented this support in trunk (see SLING-1998 [1]) and described it on the Request Parameter Handling page [2]. Regards Felix [1] https://issues.apache.org/jira/browse/SLING-1998 [2] http://sling.apache.org/site/request-parameters.html Am Freitag, den 25.02.2011, 16:12 +0000 schrieb Felix Meschberger: > Hi, > > The problem is that browsers tend to not tell the character encoding > used when posting data ... Don't ask me why ;-) > > So we have to do guessing, something I really do not like. > > But it looks like browsers send POST data in the same encoding as the > form was received as. So if the form is received as UTF-8 encoded, > browsers send back encoded in UTF-8. > > Now, how does Sling know what encoding has been used to send the form ? > Short answer: It cannot know. > > Hence the _charset_ request parameter. > > But listening to our clients and users and understanding that most of > the time UTF-8 is used anyway, how about this solution: > > * We stick with the _charset_ parameter. Whatever that parameter > conveys is used to decode parameters. > * If the parameter does not exist, we support a new configuration > option defining the default encoding to be used. > * If the configuration option is also missing, we default to the > same value as we do today; which is ISO-8859-1 > > Of course the configuration option would not be set by default (for > backwards compatibility reasons). > > Would that help your case ? > > Regards > Felix > > Am Mittwoch, den 20.10.2010, 14:05 -0400 schrieb sam lee: > > according to: > > http://download.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getCharacterEncoding%28%29 > > request.getCharacterEncoding() should return " the name of the character > > encoding used in the body of this request. ". > > > > But request.getCharacterEncoding() always seems to return ISO-8859-1. > > For example, my html.jsp looks like: > > <%@ page language="java" contentType="text/html; charset=UTF-8" > > pageEncoding="UTF-8"%> > > ... > >
> accept-charset="utf-8" > > enctype="application/x-www-form-urlencoded; charset=utf-8"> > > > > > > ... > > > > Then I would expect request.getCharacterEncoding() (from POST.jsp) to > > return "UTF-8". But it still returns "ISO-8859-1". > > > > Is this intended? > > > > >From sling documentation: > > http://sling.apache.org/site/request-parameters.html#RequestParameters-CharacterEncoding > > I don't get this part: "This identity transformation happens to generate > > strings as the original data was generated with ISO-8859-1 encoding." > > > > As long as I set _charset_ to the encoding of the rendered page (with > > ), I don't have a problem. But, I was wondering if > > .getCharacterEncoding() should be set to whatever request body was encoded > > as, not what sling used to perform "identity transform" with. > > > > Also, wouldn't it be better if _charset_ is missing from request, it's > > automatically set to request body encoding? Or, browsers don't send request > > body encoding information? > > > > Thanks. > > Sam > >