Richard Hansen <rhan...@bbn.com> added the comment: I thought about raw_unicode_escape more, and there's a way to escape quotes: use unicode escape sequences (e.g., ur'\u0027'). I've attached a new patch that does the following:
* backslash-escapes single quotes when encoding with the unicode_escape codec (the original subject of this bug) * replaces single quotes with \u0027 when encoding with the raw_unicode_escape codec (a separate bug not related to the original report, but brought up in comments) * replaces backslashes with \u005c when encoding with the raw_unicode_escape codec (a separate bug not related to the original report) * fixes a corner-case bug where the UTF-16 surrogate pair decoding logic could read past the end of the provided Py_UNICODE character array (a separate bug not related to the original report) * eliminates redundant code in PyUnicode_EncodeRawUnicodeEscape() and unicodeescape_string() * general cleanup in unicodeescape_string() The changes in the patch are non-trivial and have only been lightly tested. ---------- Added file: http://bugs.python.org/file15742/unicode_escape_reorg.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7615> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com