UTF-8 issues on Linux
Hi Guys,
I have a XML file that I stream through the request using Apache HttpClient.
I get this request and read into a buffered stream into a byte array. I then try to convert this array to a string setting UTF-8 as the encoding. Works fine on Windows. Linux I still get ? in place of my Spanish characters. To test I write the bytes from the request to a file, no problem I see the characters, but once I convert to a String and try to print no LUCK. In windows I don't even have to set the UTF-8 and it works, but if I do it gives me the ?. Here is some code. I have no idea why this does not work on linux. I have set all the encoding and the java switch Tomcat to run with UTF-8. All xml specifies UTF-8.
Linux Ubuntu Server edition (last stable)
Java 1.5.11
Tomcat 5.5
Thanks for any help!!!!
////////////////// XML POST Requests //////////////////////
public void service_POST(HttpServletRequest req, HttpServletResponse res)
throws Exception
{
String xml ="";
// [2] Read message body
req.setCharacterEncoding("UTF-8");
int contentLength = req.getContentLength();
ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
BufferedReader in = req.getReader();
for(int i = 0; i < contentLength; i++)
{
int ch = in.read();
if(ch < 0) break;
byteArray.write(ch);
}
in.close();
xml = byteArray.toString("UTF-8");
log.info("POST " +xml);
//TODO return error response to client
if(xml==null)
return;
//get the method name
String methodName = XmlRequestParser.parseRequestMethod(xml);

