encodings text betwen PC and MAC with socket


I have sockets application
When PC and MAC receive string datas all character accent are strange and diffrents on PC or MAC. like this

  • PC or mac send command and string data ( example : “MYNAME”)

  • client receive command like close connexion and display
    msgbox “server " + data + " a ferm la connexion”

  • the Word “ferm” change to ferm? or ferm@A etc etc
    pc or mac is server it is always same problem
    I undestand is the string data the problem because without it, all is ok in msgbox
    I don’t know who convert or encoding data to have universal french accent character

The data from the socket is just a series of bytes with no encoding attached. In other words, even though you understand that those bytes are meant to represent text, the app does not. It’s up to you to define the encoding on the receiving end to match what was sent (probably UTF-8 unless you did something special on the sending side). When Xojo tries to combine a series of strings when one of the encodings is unknown, it results in a string whose encoding is unknown, hence the loss of data.

Before you use the socket data, do this:

data = data.DefineEncoding( Encodings.UTF8 )

That will tell the app how to interpret the bytes that make up the text and it will be able to properly combine it with other strings.

Thanks a lot KEM