I have an API that returns XML, it actually returns it using the default encoding (I believe it's UTF-8), but now requirements have changed and we need to return everything in UTF-16LE.
My question is: is there an easy way of doing this? I have access to the response just before the calls complete so I was wondering if I could do something like
//This method does not exist
response.setCharacterEncoding("UTF-16LE");
Thanks a lot!
UPDATE: The method mentioned is the one to use. I was using an old version (2.3) of the servlet API that did not include it. Changing the version fixed it all.
just do the following thing:
As others have stated, use either:
or:
...but make sure you do this before calling response.getWriter(); ...!
First
Then, make sure you're actually emitting that encoding!
Uhh, the method does exist, here