Python pygments.util 模块,_surrogatepair() 实例源码

我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用pygments.util._surrogatepair()

项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
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')
项目:macos-st-packages    作者:zce    | 项目源码 | 文件源码
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')
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
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')
项目:chalktalk_docs    作者:loremIpsum1771    | 项目源码 | 文件源码
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')
项目:sublimeTextConfig    作者:luoye-fe    | 项目源码 | 文件源码
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')
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
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')
项目:enkiWS    作者:juliettef    | 项目源码 | 文件源码
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')
项目:python-flask-security    作者:weinbergdavid    | 项目源码 | 文件源码
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')
项目:blender    作者:gastrodia    | 项目源码 | 文件源码
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')
项目:yatta_reader    作者:sound88    | 项目源码 | 文件源码
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')