• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Text encoding problem (socket related)

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic