[jboss-jira] [JBoss JIRA] (WFLY-3376) Response endoding UTF-8 returns ISO-8859-1 endoded string
bene.net (JIRA)
issues at jboss.org
Tue May 20 05:46:58 EDT 2014
bene.net created WFLY-3376:
------------------------------
Summary: Response endoding UTF-8 returns ISO-8859-1 endoded string
Key: WFLY-3376
URL: https://issues.jboss.org/browse/WFLY-3376
Project: WildFly
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: REST
Affects Versions: 8.0.0.Final
Environment: Win7, JDK8
Reporter: bene.net
Assignee: Stuart Douglas
The REST response should be "C3A4" in HEX instead of "E3".
I didn't find a way to achieve this. It works like this in Jersey.
Please see attached files as well.
{code:title=RRResourceVersion.java}
@GET
@Produces(MediaType.TEXT_PLAIN)
public Response getTextRepresentation(@PathParam("resource-version-id") String resourceVersionId) {
Response response = null;
try {
String content = "ä";
byte[] utf8Arr = content.getBytes("UTF-8");
String hexString = RRResourceVersion.byteArray2Hex(utf8Arr);
LOGGER.info("hexString="+hexString);
String utf8Content = new String(utf8Arr, "UTF-8");
response = Response.status(Response.Status.OK).entity(utf8Content).type(MediaType.TEXT_PLAIN).encoding("UTF-8").build();
} catch (Throwable t) {
LOGGER.error("Throwable caught. ", t);
response = RestService.createResponse(MediaType.TEXT_PLAIN_TYPE, Response.Status.INTERNAL_SERVER_ERROR, RestService.throwable2String(t));
}
return response;
}
{code}
{noformat}
HTTP/1.1 200 OK
Content-Encoding: UTF-8
Connection: keep-alive
X-Powered-By: Undertow 1
Server: Wildfly 8
Content-Type: text/plain
Content-Length: 1
Date: Tue, 20 May 2014 09:31:43 GMT
ä
{noformat}
--
This message was sent by Atlassian JIRA
(v6.2.3#6260)
More information about the jboss-jira
mailing list