Python源码示例:pygments.util._surrogatepair()

示例1
def _escape_text(self, text):
        # empty strings, should give a small performance improvment
        if not text:
            return u''

        # escape text
        text = self._escape(text)

        buf = []
        for c in text:
            cn = ord(c)
            if cn < (2**7):
                # ASCII character
                buf.append(str(c))
            elif (2**7) <= cn < (2**16):
                # single unicode escape sequence
                buf.append(u'{\\u%d}' % cn)
            elif (2**16) <= cn:
                # RTF limits unicode to 16 bits.
                # Force surrogate pairs
                buf.append(u'{\\u%d}{\\u%d}' % _surrogatepair(cn))

        return u''.join(buf).replace(u'\n', u'\\par\n') 
示例2
def _escape_text(self, text):
        # empty strings, should give a small performance improvment
        if not text:
            return u''

        # escape text
        text = self._escape(text)

        buf = []
        for c in text:
            cn = ord(c)
            if cn < (2**7):
                # ASCII character
                buf.append(str(c))
            elif (2**7) <= cn < (2**16):
                # single unicode escape sequence
                buf.append(u'{\\u%d}' % cn)
            elif (2**16) <= cn:
                # RTF limits unicode to 16 bits.
                # Force surrogate pairs
                buf.append(u'{\\u%d}{\\u%d}' % _surrogatepair(cn))

        return u''.join(buf).replace(u'\n', u'\\par\n') 
示例3
def _escape_text(self, text):
        # empty strings, should give a small performance improvement
        if not text:
            return u''

        # escape text
        text = self._escape(text)

        buf = []
        for c in text:
            cn = ord(c)
            if cn < (2**7):
                # ASCII character
                buf.append(str(c))
            elif (2**7) <= cn < (2**16):
                # single unicode escape sequence
                buf.append(u'{\\u%d}' % cn)
            elif (2**16) <= cn:
                # RTF limits unicode to 16 bits.
                # Force surrogate pairs
                buf.append(u'{\\u%d}{\\u%d}' % _surrogatepair(cn))

        return u''.join(buf).replace(u'\n', u'\\par\n') 
示例4
def _escape_text(self, text):
        # empty strings, should give a small performance improvment
        if not text:
            return u''

        # escape text
        text = self._escape(text)

        buf = []
        for c in text:
            cn = ord(c)
            if cn < (2**7):
                # ASCII character
                buf.append(str(c))
            elif (2**7) <= cn < (2**16):
                # single unicode escape sequence
                buf.append(u'{\\u%d}' % cn)
            elif (2**16) <= cn:
                # RTF limits unicode to 16 bits.
                # Force surrogate pairs
                buf.append(u'{\\u%d}{\\u%d}' % _surrogatepair(cn))

        return u''.join(buf).replace(u'\n', u'\\par\n') 
示例5
def _escape_text(self, text):
        # empty strings, should give a small performance improvment
        if not text:
            return u''

        # escape text
        text = self._escape(text)

        buf = []
        for c in text:
            cn = ord(c)
            if cn < (2**7):
                # ASCII character
                buf.append(str(c))
            elif (2**7) <= cn < (2**16):
                # single unicode escape sequence
                buf.append(u'{\\u%d}' % cn)
            elif (2**16) <= cn:
                # RTF limits unicode to 16 bits.
                # Force surrogate pairs
                buf.append(u'{\\u%d}{\\u%d}' % _surrogatepair(cn))

        return u''.join(buf).replace(u'\n', u'\\par\n') 
示例6
def _escape_text(self, text):
        # empty strings, should give a small performance improvement
        if not text:
            return u''

        # escape text
        text = self._escape(text)

        buf = []
        for c in text:
            cn = ord(c)
            if cn < (2**7):
                # ASCII character
                buf.append(str(c))
            elif (2**7) <= cn < (2**16):
                # single unicode escape sequence
                buf.append(u'{\\u%d}' % cn)
            elif (2**16) <= cn:
                # RTF limits unicode to 16 bits.
                # Force surrogate pairs
                buf.append(u'{\\u%d}{\\u%d}' % _surrogatepair(cn))

        return u''.join(buf).replace(u'\n', u'\\par\n') 
示例7
def _escape_text(self, text):
        # empty strings, should give a small performance improvment
        if not text:
            return u''

        # escape text
        text = self._escape(text)

        buf = []
        for c in text:
            cn = ord(c)
            if cn < (2**7):
                # ASCII character
                buf.append(str(c))
            elif (2**7) <= cn < (2**16):
                # single unicode escape sequence
                buf.append(u'{\\u%d}' % cn)
            elif (2**16) <= cn:
                # RTF limits unicode to 16 bits.
                # Force surrogate pairs
                buf.append(u'{\\u%d}{\\u%d}' % _surrogatepair(cn))

        return u''.join(buf).replace(u'\n', u'\\par\n') 
示例8
def _escape_text(self, text):
        # empty strings, should give a small performance improvment
        if not text:
            return u''

        # escape text
        text = self._escape(text)

        buf = []
        for c in text:
            cn = ord(c)
            if cn < (2**7):
                # ASCII character
                buf.append(str(c))
            elif (2**7) <= cn < (2**16):
                # single unicode escape sequence
                buf.append(u'{\\u%d}' % cn)
            elif (2**16) <= cn:
                # RTF limits unicode to 16 bits.
                # Force surrogate pairs
                buf.append(u'{\\u%d}{\\u%d}' % _surrogatepair(cn))

        return u''.join(buf).replace(u'\n', u'\\par\n') 
示例9
def _escape_text(self, text):
        # empty strings, should give a small performance improvment
        if not text:
            return u''

        # escape text
        text = self._escape(text)

        buf = []
        for c in text:
            cn = ord(c)
            if cn < (2**7):
                # ASCII character
                buf.append(str(c))
            elif (2**7) <= cn < (2**16):
                # single unicode escape sequence
                buf.append(u'{\\u%d}' % cn)
            elif (2**16) <= cn:
                # RTF limits unicode to 16 bits.
                # Force surrogate pairs
                buf.append(u'{\\u%d}{\\u%d}' % _surrogatepair(cn))

        return u''.join(buf).replace(u'\n', u'\\par\n')