当前位置: 首页>>代码示例>>Python>>正文


Python util._surrogatepair方法代码示例

本文整理汇总了Python中pygments.util._surrogatepair方法的典型用法代码示例。如果您正苦于以下问题:Python util._surrogatepair方法的具体用法?Python util._surrogatepair怎么用?Python util._surrogatepair使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygments.util的用法示例。


在下文中一共展示了util._surrogatepair方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _escape_text

# 需要导入模块: from pygments import util [as 别名]
# 或者: from pygments.util import _surrogatepair [as 别名]
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') 
开发者ID:joxeankoret,项目名称:pigaios,代码行数:25,代码来源:rtf.py

示例2: _escape_text

# 需要导入模块: from pygments import util [as 别名]
# 或者: from pygments.util import _surrogatepair [as 别名]
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') 
开发者ID:pygments,项目名称:pygments,代码行数:25,代码来源:rtf.py


注:本文中的pygments.util._surrogatepair方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。