unicode and socket

aurora aurora00 at gmail.com
Sat Feb 19 12:09:55 EST 2005


On 18 Feb 2005 19:10:36 -0800, <zyqnews at 163.net> wrote:

> It's really funny, I cannot send a unicode stream throuth socket with
> python while all the other languages as perl,c and java can do it.
> then, how about converting the unicode string to a binary stream? It is
> possible to send a binary through socket with python?
>

I was answering your specific question:

"How can I send the unicode string to the remote end of the socket as it  
is without any conversion of encode"

The answer is you could not. Not that you cannot sent unicode but you have  
to encode it. The same applies to perl, c or Java. The only difference is  
the detail of how strings get encoded.

There are a few posts suggest various means. Or you can check out  
codecs.getwriter() which closer resembles Java's way.



More information about the Python-list mailing list