本文整理汇总了Python中helper.H.unicode_chr方法的典型用法代码示例。如果您正苦于以下问题:Python H.unicode_chr方法的具体用法?Python H.unicode_chr怎么用?Python H.unicode_chr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helper.H
的用法示例。
在下文中一共展示了H.unicode_chr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: convert
# 需要导入模块: from helper import H [as 别名]
# 或者: from helper.H import unicode_chr [as 别名]
def convert(matches):
text = matches.group(0)
# Character reference
if text[:2] == "&#":
try:
if text[:3] == "&#x":
return H.unicode_chr(int(text[3:-1], 16))
else:
return H.unicode_chr(int(text[2:-1]))
except ValueError:
pass
# Named entity
else:
try:
# Following are not needed to be converted for XML
if text[1:-1] == "amp" or text[1:-1] == "gt" or text[1:-1] == "lt":
pass
else:
text = H.unicode_chr(name2codepoint[text[1:-1]])
except KeyError:
pass
return text
示例2: Protocol
# 需要导入模块: from helper import H [as 别名]
# 或者: from helper.H import unicode_chr [as 别名]
from .elementtree import SimpleXMLTreeBuilder
ET.XMLTreeBuilder = SimpleXMLTreeBuilder.TreeBuilder
ILLEGAL_XML_UNICODE_CHARACTERS = [
(0x00, 0x08), (0x0B, 0x0C), (0x0E, 0x1F), (0x7F, 0x84),
(0x86, 0x9F), (0xD800, 0xDFFF), (0xFDD0, 0xFDDF),
(0xFFFE, 0xFFFF),
(0x1FFFE, 0x1FFFF), (0x2FFFE, 0x2FFFF), (0x3FFFE, 0x3FFFF),
(0x4FFFE, 0x4FFFF), (0x5FFFE, 0x5FFFF), (0x6FFFE, 0x6FFFF),
(0x7FFFE, 0x7FFFF), (0x8FFFE, 0x8FFFF), (0x9FFFE, 0x9FFFF),
(0xAFFFE, 0xAFFFF), (0xBFFFE, 0xBFFFF), (0xCFFFE, 0xCFFFF),
(0xDFFFE, 0xDFFFF), (0xEFFFE, 0xEFFFF), (0xFFFFE, 0xFFFFF),
(0x10FFFE, 0x10FFFF) ]
ILLEGAL_XML_RANGES = ["%s-%s" % (H.unicode_chr(low), H.unicode_chr(high))
for (low, high) in ILLEGAL_XML_UNICODE_CHARACTERS
if low < sys.maxunicode]
ILLEGAL_XML_RE = re.compile(H.unicode_string('[%s]') % H.unicode_string('').join(ILLEGAL_XML_RANGES))
class Protocol(object):
"""
Class for connecting with debugger engine which uses DBGp protocol.
"""
# Maximum amount of data to be received at once by socket
read_size = 1024
示例3: Protocol
# 需要导入模块: from helper import H [as 别名]
# 或者: from helper.H import unicode_chr [as 别名]
(0x5FFFE, 0x5FFFF),
(0x6FFFE, 0x6FFFF),
(0x7FFFE, 0x7FFFF),
(0x8FFFE, 0x8FFFF),
(0x9FFFE, 0x9FFFF),
(0xAFFFE, 0xAFFFF),
(0xBFFFE, 0xBFFFF),
(0xCFFFE, 0xCFFFF),
(0xDFFFE, 0xDFFFF),
(0xEFFFE, 0xEFFFF),
(0xFFFFE, 0xFFFFF),
(0x10FFFE, 0x10FFFF),
]
ILLEGAL_XML_RANGES = [
"%s-%s" % (H.unicode_chr(low), H.unicode_chr(high))
for (low, high) in ILLEGAL_XML_UNICODE_CHARACTERS
if low < sys.maxunicode
]
ILLEGAL_XML_RE = re.compile(H.unicode_string("[%s]") % H.unicode_string("").join(ILLEGAL_XML_RANGES))
class Protocol(object):
"""
Class for connecting with debugger engine which uses DBGp protocol.
"""
# Maximum amount of data to be received at once by socket
read_size = 1024