[ANN] pyxser-1.2r --- Python-Object to XML serialization module
Daniel Molina Wegener
dmw at coder.cl
Tue Aug 25 14:08:02 CEST 2009
-----BEGIN PGP SIGNED MESSAGE-----
Stefan Behnel <stefan_ml at behnel.de>
on Tuesday 25 August 2009 01:23
wrote in comp.lang.python:
> Stefan Behnel wrote:
>> for all byte
>> strings, regardless of their encoding (since you can't even know if they
>> represent encoded text at all).
> Hmm, having written that, I guess it's actually best to encode byte
> strings as base64 instead. Otherwise, null bytes and other special byte
> values won't pass.
Sure, base64 is a good option for byte string input.
> I also think that if the user wants readable output for text strings, it's
> reasonable to require Unicode input instead of byte strings. Handling text
> in byte strings is just too error prone.
> Still, you may have to sanitize text input to make sure it doesn't contain
> special characters either. Take a look at the way lxml does it in the
> apihelpers.pxi source file, or read the XML spec on character content.
Thanks, I will look for that. I must to do a better implementation on
handling byte strings, since would be many cases on where encoded strings
are mixed. For example different database inputs with different
encodings --- if those byte strings are not readed as Unicode strings.
Both sanitizing and base64 encoding are good options, and also, both are
readable from other platforms. The problem with later implementations of
pyxser was that it was using *RawUnicodeEscape* which is not readable from
.O. | Daniel Molina Wegener | FreeBSD & Linux
..O | dmw [at] coder [dot] cl | Open Standards
OOO | http://coder.cl/ | FOSS Developer
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (FreeBSD)
-----END PGP SIGNATURE-----
More information about the Python-list