Created
August 5, 2010 03:06
-
-
Save niallo/509164 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_xml_escapes = (tuple([('%c' % z, '\\u%04X' % z) | |
for z in range(20) if z not in (0x9, 0xA, 0xD)])) | |
def escape_low_xml(value): | |
''' Escape every ASCII character with a value less than 20 except for | |
certain codes allowed by XML v1.0 spec ''' | |
for bad, good in _xml_escapes: | |
value = value.replace(bad, good) | |
return value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment