Did you try using $utfencode before sending the information via the socket?

And while I'm here, why did you post this in the Connection Issues section, as it seems to have nothing to do with connecting.