users@jersey.java.net

Re: [Jersey] Multipart Form And Encoding

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 02 Nov 2009 12:04:08 +0100

Hi Jordi,

I have verified there is a bug in the FormDataBodyPart.getValue
method. It is ignoring the charset parameter (if present) on the media
type.

In fact this method is doing it's own string parsing when it should be
deferring to the string reader provided of the message body reader.

Can you:

1) verify there is a charset parameter present on the Content-Type of
the body part identified as "name"; and

2) try doing the following and seeing if that works (which depends on
a charset parameter with a value of "ISO-8859-1" being present)

   multiPart.getField("name").getValueAs(String.class);

Paul.



On Nov 2, 2009, at 11:49 AM, Jordi Domingo wrote:

> Hi,
>
> I've got some problems with char encoding using multipart API. I've
> been able to solve this in my pc using:
>
> String name = multiPart.getField("name").getValue();
> name = new String(name.getBytes("ISO-8859-1"), "UTF-8");
>
> But in production it is not working. Chars like àáèéìí ... are shown
> like ??
>
> Any help is appreciated. Thanks,
>
> Jordi
>
> Entra al Nuevo Canal Motor y descubre por qué los coches más rápidos
> sólo aparcan en MSN. Nuevo diseño, más completo y abierto a tu
> opinión.¡Nuevo Canal Motor!