Marshaling unicode WDDX

"Martin v. Löwis" martin at v.loewis.de
Thu Jan 5 20:44:55 CET 2006


isthar wrote:
> WDDX is perfect for me for exchange between python and php application.
> but maybe there is a better way to do it.

It appears that Unicode objects where forgotten in the WDDX
implementation. I suggest to define the following classes:

class UWDDXMarshaller(xml.marshal.wddx.WDDXMarshaller):
  def m_unicode(self, data, dict):
    return self.m_string(data.encode("utf-8"), dict)

class UWDDXUnmarshaller(xml.marshal.wddx.WDDXUnmarshaller):
  def um_end_string(self, name):
    ds = self.data_stack
    ds[-1] = u"".join(ds[-1])
    self.accumulating_chars = 0

The m_unicode part should get integrated into PyXML;
the um_end_string should probably return ASCII strings
if possible, else Unicode strings.

Regards,
Martin



More information about the Python-list mailing list