Menu

#129 Parsing of types derived from xsd:string fails on accents

v2.0
open
nobody
zsi (169)
5
2006-05-02
2006-05-02
No

When using a type derived (by restriction) from
xsd:string, the conversion of a string including
accents fails with an ascii encoding error, while it
works with the original schema type string.

To reproduce the error, just define in XML-Schema a
type derived from string by restriction (with nothing
for the restriction), define an operation with an
argument of that type, and call the operation via ZSI
with a string including accent(s). Then in your ZSI
server implementation, call Parse() on the SOAP
received, this should trigger the error in
TC..String.text_to_data() -> Ascii encoding error, char
ordinal out of range, etc...

The workaround I have used so far is to encode the text
to UTF8 in text_to_data() if it was unicode. I don't
know if it's pertinent for all cases, though. Here is a
patch for ZSI 2.0 RC2:

766c766,770
< return self.pyclass(text)
---
> # Encode to UTF8 if unicode to avoid
ascii encoding
> # error when calling self.pyclass()
> if isinstance(text, unicode):
> text = text.encode('utf8')
> return self.pyclass(text)

Richard

Discussion


Log in to post a comment.