This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients ncoghlan
Date 2013-08-23.04:02:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Prompted by issue 18713 and, here are some possible utilities we could add to the codecs module to help deal with/debug issues related to surrogate escaped strings:

    def has_escaped_bytes(s):
        """Returns true if string contains surrogate escaped bytes"""

    def replace_escaped_bytes(s):
        """Replaces each surrogate escaped byte with a valid code point"""

    def decode_escaped_bytes(s, nominal_encoding, actual_encoding):
        """Reinterprets incorrectly decoded text using a new encoding"""
        return s.encode(nominal_encoding, 'surrogateescape').decode(actual_encoding)
Date User Action Args
2013-08-23 04:02:32ncoghlansetrecipients: + ncoghlan
2013-08-23 04:02:32ncoghlansetmessageid: <>
2013-08-23 04:02:31ncoghlanlinkissue18814 messages
2013-08-23 04:02:31ncoghlancreate