users@jersey.java.net

Response into UTF-16 encoding

From: Patrick Sauts <psauts_at_viadeoteam.com>
Date: Mon, 12 Apr 2010 18:32:32 +0200

Hi,

 

The problem we are facing is that we need to produce a special xml
format with a char encoding in UTF-16,

To do that we've written a @Provider for our specific format

@Produces("specialxlm/xml; charset=UTF-16")

@Provider

public class SpecialXMLProvider ...

 

The xml produced is UTF-16 encoded and has the good format but the xml
header is still :

<?xml version="1.0" encoding="UTF-8">

 

The "javax.ws.rs.core.Response" is made using :

Response.ok().entity(new JSONWithPadding(new
GenericEntity<ResponseSpecialXml>(responseSpecialXml) {})).build();

 

My question is, how with this kind of implementation, do I obtain a xml
response header like :

<?xml version="1.0" encoding="UTF-16">

 

Thank you for your time.

 

Patrick Sauts.