Encode HTML CDATA name token

Gregor Horvath gh at gregor-horvath.com
Mon Sep 20 10:45:46 CEST 2010


Hi,

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
followed by any number of letters, digits ([0-9]), hyphens ("-"),
underscores ("_"), colons (":"), and periods ("."). [1]

Is there a encoder / decoder in Python that can convert arbitrary text
to and from this encoding in an readable manner?

base64 is not readable:

In [31]: base64.encodestring("/TEST")
Out[31]: 'L1RFU1Q=\n'

quopri does not encode for example "/".

In [25]: quopri.encodestring("/test")
Out[25]: '/test'

Anything else?

--
Greg

[1] http://www.w3.org/TR/html4/types.html#type-cdata



More information about the Python-list mailing list