wddx problem with entities

T

Tim Arnold

I'm confused about why I get this error:
UnicodeError: ASCII encoding error: ordinal not in range(128)

when I try to load a wddx file containing this string:
<string>The image file, gif/aperçu.png, does
not exist.</string>

When I loop through the file as if it's text and check the ord() value of
each character, of course it's clean. Do I have to replace numbered entities
in the wddx file before I can wddx.load() it?
thanks!
--tim

example program:
-------------------
from xml.marshal import wddx

datastring = '''<?xml version="1.0"?>
<!DOCTYPE wddxPacket SYSTEM "wddx_0090.dtd">
<wddxPacket version="0.9">
<header/>
<data><struct>
<string>The image file, gif/aperçu.png,does not exist.</string>
</struct></data></wddxPacket>'''

data = wddx.loads(datastring)
 
T

Tim Arnold

Tim Arnold said:
I'm confused about why I get this error:
UnicodeError: ASCII encoding error: ordinal not in range(128)

when I try to load a wddx file containing this string:
<string>The image file, gif/aperçu.png, does
not exist.</string>

When I loop through the file as if it's text and check the ord() value of
each character, of course it's clean. Do I have to replace numbered
entities in the wddx file before I can wddx.load() it?
thanks!
--tim

example program:
-------------------
from xml.marshal import wddx

datastring = '''<?xml version="1.0"?>
<!DOCTYPE wddxPacket SYSTEM "wddx_0090.dtd">
<wddxPacket version="0.9">
<header/>
<data><struct>
<string>The image file, gif/aperçu.png,does not exist.</string>
</struct></data></wddxPacket>'''

data = wddx.loads(datastring)

Replying to my own post.
I got around this problem, which *looks* like a bug to me, (although I'm
sure I don't understand the internals of xml.marshal) with this:

self.data = wddx.loads(''.join(codecs.open(self.filename,
errors='ignore',encoding='ascii').readlines()))
where self.filename contains the numbered entity.

just in case anyone else out there is using wddx to communicate between
python and php.

--Tim Arnold
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top