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);

[1688 byte] By [supsoop2a] at [2007-11-27 11:12:51]
# 1

Hey Guys, i fixed the problem, maybe this can help others with this UTF-8 issue. Not sure why I have to do it like this but it works!! Maybe others can shed some light

Replaced the string conversion with this line:

xml = new String(byteArray.toString("ISO8859-1").getBytes(),"UTF-8");

supsoop2a at 2007-7-29 13:57:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...