Utility method to produce an escaped version of a given
        string.

        :param string: The string to escape.

        :returns: The escaped version of the string.

def escape(cls, string):
        """
        Utility method to produce an escaped version of a given
        string.

        :param string: The string to escape.

        :returns: The escaped version of the string.
        """

        return ''.join([cls._escapes[c] if cls._needescape(c) else c
                        for c in string.encode('utf8')])