[Twisted-Python] Sending unicode strings
tv at twistedmatrix.com
Sat Apr 23 02:17:44 EDT 2005
Michal Chruszcz wrote:
> Why do you mean it? Why I can't send unicode through twisted? It's
> ridiculous that I have to convert UTF8 strings to ISO on the client side
... to convert Unicode strings to UTF-8 on the client side ...
> and then once again from ISO to UTF8 on the server side, so I suppose
...from UTF-8 to Unicode on the server side...
Personally, I think ass-u-ming Unicode is encoded as UTF-8 would have
been sane, but I can understand that not everyone agrees; e.g. Java
wants UCS-16 if I remember correctly. And not serializing to UTF-8
by default catches errors that would otherwise cause mysterious things
Maybe add a transport wrapper class that has
def write(self, data):
if isinstance(data, unicode):
data = self.serializeUnicode(data)
of course, that means the Protocol receiving this needs to convert from
the used serialization format to Unicode.
More information about the Twisted-Python