commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ylva Degerfeldt" <ylva.degerfe...@gmail.com>
Subject Re: Reading unicode characters from a form in multipart/form-data format
Date Tue, 06 May 2008 12:46:45 GMT
Thank you, Jason and Christian!

Jason, I tried changing "UTF-8" to "utf-8" in all the places where I'm
using it but that didn't work. But thanks anyway!

Thank you, Christian for showing me a solution to the problem!
The getBytes thing was the important part, but I had to solve it like this:
String newName = new String(oldName.getBytes("ISO-8859-1"), "utf-8");

Anyway, now it Works and that's GREAT!!
Tack!!

/Ylva

On Tue, May 6, 2008 at 8:42 AM, Christian Andersson <ca@ofs.no> wrote:
> Hi there, if you don't get it solved with the new jar that you got from Song
> Jason youmight try to convert the text yourself.. (I have done this when
> I've been using commons fileupload.
>
>  what is happening is that commons fileupload is reading the text as if it
> was encoded in ISO-8859-1, so here is what I have been using to convert it
> to UTF-8
>
>  String name = ...   // get parameter from commons file upload
>  name =name.getBytes("ISO-8859-1"),"UTF-8");
>
>
>
>
>  Ylva Degerfeldt skrev:
>
> >
> >
> >
> > Hi everyone!
> >
> > I joined this list in hope of that someone can help me with this problem:
> >
> > Is there a way to use UTF-8 when reading from form fields with
> > multipart/form-data format? (I'm using Apache commons
> > ServletFileUpload so that's why I'm asking on this mailing list.)
> >
> > I've searched the web for answers and though this seems to be a well
> > known problem, I haven't found any solution to it.
> >
> > I have to have a multipart/form-data form because I want the users to
> > be able to save their names and birthdate on the same jsp page as
> > where they can upload a (cv) file, so I have to find a solution.
> >
> > My jsp page has the meta tag attribute charset="UTF-8", the form has
> > the attribute accept-charset="UTF-8" and in the servlet which receives
> > this request I do a:
> >
> > request.setCharacterEncoding("UTF-8");
> >
> > but none of those things seem to help.
> >
> > I also tried using the setHeaderEncoding method of the
> > ServletFileUpload class but that didn't help either. I still receive
> > Swedish characters as "weird looking characters" and that's not what I
> > want.
> >
> > If anyone has a solution to this problem I would be Very grateful!
> > (Even if the solution means that I have to convert the strings I
> > receive in some way.)
> >
> > Thanks in advance,
> >
> > Ylva
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> > For additional commands, e-mail: user-help@commons.apache.org
> >
> >
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>  For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message