本文整理汇总了Python中codecs.utf_32_decode方法的典型用法代码示例。如果您正苦于以下问题:Python codecs.utf_32_decode方法的具体用法?Python codecs.utf_32_decode怎么用?Python codecs.utf_32_decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类codecs
的用法示例。
在下文中一共展示了codecs.utf_32_decode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_decode_unicode
# 需要导入模块: import codecs [as 别名]
# 或者: from codecs import utf_32_decode [as 别名]
def test_decode_unicode(self):
# Most decoders don't accept unicode input
decoders = [
codecs.utf_7_decode,
codecs.utf_8_decode,
codecs.utf_16_le_decode,
codecs.utf_16_be_decode,
codecs.utf_16_ex_decode,
codecs.utf_32_decode,
codecs.utf_32_le_decode,
codecs.utf_32_be_decode,
codecs.utf_32_ex_decode,
codecs.latin_1_decode,
codecs.ascii_decode,
codecs.charmap_decode,
]
if hasattr(codecs, "mbcs_decode"):
decoders.append(codecs.mbcs_decode)
for decoder in decoders:
self.assertRaises(TypeError, decoder, "xxx")
示例2: decode
# 需要导入模块: import codecs [as 别名]
# 或者: from codecs import utf_32_decode [as 别名]
def decode(input, errors='strict'):
return codecs.utf_32_decode(input, errors, True)
示例3: test_handlers
# 需要导入模块: import codecs [as 别名]
# 或者: from codecs import utf_32_decode [as 别名]
def test_handlers(self):
self.assertEqual((u'\ufffd', 1),
codecs.utf_32_decode('\x01', 'replace', True))
self.assertEqual((u'', 1),
codecs.utf_32_decode('\x01', 'ignore', True))
示例4: test_errors
# 需要导入模块: import codecs [as 别名]
# 或者: from codecs import utf_32_decode [as 别名]
def test_errors(self):
self.assertRaises(UnicodeDecodeError, codecs.utf_32_decode,
"\xff", "strict", True)
示例5: test_issue8941
# 需要导入模块: import codecs [as 别名]
# 或者: from codecs import utf_32_decode [as 别名]
def test_issue8941(self):
# Issue #8941: insufficient result allocation when decoding into
# surrogate pairs on UCS-2 builds.
encoded_le = '\xff\xfe\x00\x00' + '\x00\x00\x01\x00' * 1024
self.assertEqual(u'\U00010000' * 1024,
codecs.utf_32_decode(encoded_le)[0])
encoded_be = '\x00\x00\xfe\xff' + '\x00\x01\x00\x00' * 1024
self.assertEqual(u'\U00010000' * 1024,
codecs.utf_32_decode(encoded_be)[0])
示例6: test_handlers
# 需要导入模块: import codecs [as 别名]
# 或者: from codecs import utf_32_decode [as 别名]
def test_handlers(self):
self.assertEqual(('\ufffd', 1),
codecs.utf_32_decode(b'\x01', 'replace', True))
self.assertEqual(('', 1),
codecs.utf_32_decode(b'\x01', 'ignore', True))
示例7: test_errors
# 需要导入模块: import codecs [as 别名]
# 或者: from codecs import utf_32_decode [as 别名]
def test_errors(self):
self.assertRaises(UnicodeDecodeError, codecs.utf_32_decode,
b"\xff", "strict", True)
示例8: test_issue8941
# 需要导入模块: import codecs [as 别名]
# 或者: from codecs import utf_32_decode [as 别名]
def test_issue8941(self):
# Issue #8941: insufficient result allocation when decoding into
# surrogate pairs on UCS-2 builds.
encoded_le = b'\xff\xfe\x00\x00' + b'\x00\x00\x01\x00' * 1024
self.assertEqual('\U00010000' * 1024,
codecs.utf_32_decode(encoded_le)[0])
encoded_be = b'\x00\x00\xfe\xff' + b'\x00\x01\x00\x00' * 1024
self.assertEqual('\U00010000' * 1024,
codecs.utf_32_decode(encoded_be)[0])