• Post Reply Bookmark Topic Watch Topic
  • New Topic

Text encoding problem (socket related)  RSS feed

 
Karl Svensson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I have a problem. I am sending a string (encapsulated in another object, so I'm using object streams to read and write the data) to another computer through a socket. The string is then matched against a dictionary read locally on the receiver's computer to see which words can be formed using the characters in the string (yes, this is a game). I am using a Mac, and when I send the string to another Mac everything seems to work as expected. But when I send it to a Windows computer, "non-English characters" (i.e. not A-Z) are not translated correctly, so words that contain the Swedish letters �, � and � are not found even though they actually appear in the dictionary. I thought Unicode would guarantee this to work without having to explicitly tell Java about different encodings and things like that, but it doesn't. Does anyone know how to solve this..?
 
Karl Svensson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll try to ask my question in a shorter way: When receiving a string through a socket, is a different encoding used than when reading a string from a file?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you specifically saying everywhere that you want to use UTF-8? There are a few spots in the API where it will use a platform-specific encoding if you don't specify that you want to use UTF-8. That could be MacRoman or Cp-1252, which are the default encodings on Macs and Windows, respectively, and which are incompatible with regard to accented characters.
 
Karl Svensson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
Are you specifically saying everywhere that you want to use UTF-8?.


Actually I hadn't, but your answer led me in the right direction. Now it works. Thank you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!