This discussion is archived
2 Replies Latest reply: Sep 19, 2009 1:25 AM by 807580 RSS

Java charset and string encoding

807580 Newbie
Currently Being Moderated
Picture the following scenario. A server (running on Windows) sends an object to a client (running on Linux), over a socket connection. This object contains, among other things, a search path in the form of a string. Now, at some point the client takes this string and transforms it into bytes with the getBytes()-method and sends the byte[]-array back to the server. The server recives this and creates the string again with new String(byte[]). Here arise a problem, some of the characters in the original string have now been replaced by noncens.

I know this is due to the fact that the character encoding differ between windows and linux but how can i get around this? Can i somehow specify which character encoding the getBytes()-method should use? I know there is something in java called Charset but i cant figure out how to use it. Anyone got any ideas?


Thanks / MTy