A special character is appended before § A special character is appended before § linux linux

A special character is appended before §


This is almost certainly a character encoding issue. To avoid mismatches between client and server, always specify a specific encoding and avoid the default encoding. (So, for instance, instead of "xyz".getBytes(), use "xyz".getBytes("UTF-8")


The error you are seeing here is because the Linux server defaults to sending the String as UTF-8. In UTF-8, regular ASCII characters are encoded as a single byte. The § character is encoded as two bytes. If you decode this using CP-1252, you will see § because the two bytes are interpreted as two separate characters.

The windows server will use http://en.wikipedia.org/wiki/Windows-1252, which can encode the § as a single byte.

If you are using your own protocol, you should specify which character encoding to use over the wire. I suggest you default to UTF-8 (internet standard). When sending the string, you should use "xyz".getBytes("UTF-8"). If you receive the string, you should use new String(bytes, "UTF-8").

If you are using HTTP, your client should honor the headers in section 14 of the HTTP spec. I propose you use an implemented HTTP client like Apache Commons HTTPClient or the built-in J2SE one. On the server-side, you should use the response.getWriter() method in the Servlet to get a writer which will automatically use the agreed encoding. Please note you cannot just output bytes, since the server and client may have agreed upon another transfer-encoding for the HTTP stream!