|
From: Knut H. <knu...@to...> - 2010-02-22 14:47:43
|
Hi,
I have a problem, that my service should always respond in UTF-8 and I
set the @Produces accordingly (
"...;charset=UTF-8")). My service method returns a string containing
german umlauts.
Unfortunately, the service returns those umlauts encoded in ISO8859-1
(or so) and not in UTF-8.
I did a litte debugging and found out that the StringTextStar writeTo
method does a o.getBytes() on the result String, but
does not provide the required codeset, or alternatively the
entityStream.write does not use a codeset, so that I assume
it takes the codeset from the locale the server runs in. In my view, the
writeTo() method should use the codeset as specified
in the mediaType (if given). Do you have easy methods to extract the
charset from the mediaType?
To test, just write a little hello world service:
<code>
@GET
@Path("/hello")
@Produces("text/plain;charset=UTF-8")
public String hello(@Context HttpServletRequest request) {
return "Hallo schnöde Welt!" + request.toString();
}
</code>
--
------------------------------------------------------------
Knut H. Hertel
TOLERANT Software GmbH & Co. KG, Forststr.7, 70174 Stuttgart
Tel +49 711 490 448 56, Fax +49 711 490 448 36
knu...@to..., http://www.tolerant-software.de/
Persönlich haftender Gesellschafter: TOLERANT Software Verwaltungs-GmbH,
Amtsgericht Stuttgart, HRB 730593
Vertretungsberechtigte Geschäftsführer: Dr. Markus Eberspächer, Stefan Sedlacek, Jörg Vogler
Registergericht: Amtsgericht Stuttgart, HRA 724238
|