本文整理汇总了Python中pyaid.string.StringUtils.StringUtils.unicodeToStr方法的典型用法代码示例。如果您正苦于以下问题:Python StringUtils.unicodeToStr方法的具体用法?Python StringUtils.unicodeToStr怎么用?Python StringUtils.unicodeToStr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyaid.string.StringUtils.StringUtils
的用法示例。
在下文中一共展示了StringUtils.unicodeToStr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unpack
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import unicodeToStr [as 别名]
def unpack(self, dataType, length):
data = StringUtils.unicodeToStr(self.read(length))
assert len(data) == length, \
u"[UNPACK ERROR]: Unexpected end of stream [%s | %s]" % (
StringUtils.toUnicode(len(data)), StringUtils.toUnicode(length))
try:
return struct.unpack(StringUtils.unicodeToStr(self.endianess + dataType), data)[0]
except struct.error:
print(len(data))
print(u"Unable to unpack '%r'" % data)
raise
示例2: itemsToString
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import unicodeToStr [as 别名]
def itemsToString(cls, target, inPlace =False, toUnicode =True):
""" Iterates through the elements of the target list and converts each of them to binary
strings, including decoding unicode strings to byte strings."""
from pyaid.string.StringUtils import StringUtils
output = target if inPlace else (target + [])
index = 0
while index < len(target):
source = target[index]
if StringUtils.isStringType(source):
if toUnicode:
output[index] = StringUtils.strToUnicode(source)
else:
output[index] = StringUtils.unicodeToStr(source, force=True)
else:
output[index] = str(source)
index += 1
return output
示例3: pack
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import unicodeToStr [as 别名]
def pack(self, dataType, value):
"""pack doc..."""
return struct.pack(StringUtils.unicodeToStr(self.endianess + dataType), value)
示例4: writeInt8
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import unicodeToStr [as 别名]
def writeInt8(self, value):
""" Read a signed 8bit integer."""
self.writeByte(struct.pack(StringUtils.unicodeToStr('b'), int(value)))
示例5: writeString
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import unicodeToStr [as 别名]
def writeString(self, value):
self.writeBytes(bytes(StringUtils.unicodeToStr(value)))
示例6: writeNullByte
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import unicodeToStr [as 别名]
def writeNullByte(self):
self.writeByte(struct.pack(StringUtils.unicodeToStr('x')))