SimpleXmlRpcServer and character encoding

S

shymon

I'm using SimpleXmlRpcServer class. Although I set encoding parameter in the
constructor, I have to return all strings in default platform encoding
(windows-1250/win32 or iso-8859-2/linux in my case). When I send values in,
for example, UTF-8, string received by client is messed up.

The client is written in java using Apache XmlRpc library 2.0.

Is there any solution other than sending all string values in Base64
encoding?
 
D

Diez B. Roggisch

shymon said:
I'm using SimpleXmlRpcServer class. Although I set encoding parameter in
the constructor, I have to return all strings in default platform encoding
(windows-1250/win32 or iso-8859-2/linux in my case). When I send values
in, for example, UTF-8, string received by client is messed up.

The client is written in java using Apache XmlRpc library 2.0.

Is there any solution other than sending all string values in Base64
encoding?

Use unicode-objects. And unicode IS NOT utf-8. The encoding parameter will
affect the xml generated & send over the wire - *not* what strings you
pass/return to your implementation.

So I think you should remove the encoding parameter alltogether, as this
will make the transport being in utf-8. Then use only unicode-objects in
your python code. And on the java-side, things *should* be in order.

Diez
 
S

shymon

Diez said:
Use unicode-objects. And unicode IS NOT utf-8. The encoding parameter will
affect the xml generated & send over the wire - *not* what strings you
pass/return to your implementation.

So I think you should remove the encoding parameter alltogether, as this
will make the transport being in utf-8. Then use only unicode-objects in
your python code. And on the java-side, things *should* be in order.

Diez


I have tried unicode strings also, let's say u"miłość".
Result received by the client was the same as if I sent UTF-8 encoded
string.
 
D

Diez B. Roggisch

shymon said:
I have tried unicode strings also, let's say u"miłość".
Result received by the client was the same as if I sent UTF-8 encoded
string.


Please show concrete code-examples, and the results, preferably as
repr-string, as these contain the hex-chars:

repr("ö") -> "'\\xc3\\xb6'"

The above shows that the ö is encoded in utf-8.

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top