我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用pygments.util._surrogatepair()。
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')