當前位置: 首頁>>代碼示例>>Python>>正文


Python codecs.utf_32_ex_decode方法代碼示例

本文整理匯總了Python中codecs.utf_32_ex_decode方法的典型用法代碼示例。如果您正苦於以下問題:Python codecs.utf_32_ex_decode方法的具體用法?Python codecs.utf_32_ex_decode怎麽用?Python codecs.utf_32_ex_decode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在codecs的用法示例。


在下文中一共展示了codecs.utf_32_ex_decode方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_decode_unicode

# 需要導入模塊: import codecs [as 別名]
# 或者: from codecs import utf_32_ex_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") 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:22,代碼來源:test_codecs.py

示例2: test_utf_32_ex_decode

# 需要導入模塊: import codecs [as 別名]
# 或者: from codecs import utf_32_ex_decode [as 別名]
def test_utf_32_ex_decode(self):
        self.utf_ex_decode_test_helper(
            charwidth=4,
            abc="abc",
            func=codecs.utf_32_ex_decode,
            abc_le=b'a\0\0\0b\0\0\0c\0\0\0',
            abc_be=b'\0\0\0a\0\0\0b\0\0\0c',
            bom_le=codecs.BOM_UTF32_LE,
            bom_be=codecs.BOM_UTF32_BE)

        self.assertEqual(codecs.utf_32_ex_decode(array.array('I', (0x0001f40d,))), ("\U0001f40d", 4, 0))

        self.assertRaises(TypeError, codecs.utf_32_ex_decode, "abc")
        self.assertRaises(TypeError, codecs.utf_32_ex_decode, None)
        self.assertRaises(TypeError, codecs.utf_32_ex_decode, None, None)
        self.assertEquals(codecs.utf_32_ex_decode(b"", None), ("", 0, 0)) 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:18,代碼來源:test_codecs.py

示例3: _buffer_decode

# 需要導入模塊: import codecs [as 別名]
# 或者: from codecs import utf_32_ex_decode [as 別名]
def _buffer_decode(self, input, errors, final):
        if self.decoder is None:
            (output, consumed, byteorder) = \
                codecs.utf_32_ex_decode(input, errors, 0, final)
            if byteorder == -1:
                self.decoder = codecs.utf_32_le_decode
            elif byteorder == 1:
                self.decoder = codecs.utf_32_be_decode
            elif consumed >= 4:
                raise UnicodeError("UTF-32 stream does not start with BOM")
            return (output, consumed)
        return self.decoder(input, self.errors, final) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:14,代碼來源:utf_32.py

示例4: decode

# 需要導入模塊: import codecs [as 別名]
# 或者: from codecs import utf_32_ex_decode [as 別名]
def decode(self, input, errors='strict'):
        (object, consumed, byteorder) = \
            codecs.utf_32_ex_decode(input, errors, 0, False)
        if byteorder == -1:
            self.decode = codecs.utf_32_le_decode
        elif byteorder == 1:
            self.decode = codecs.utf_32_be_decode
        elif consumed>=4:
            raise UnicodeError,"UTF-32 stream does not start with BOM"
        return (object, consumed)

### encodings module API 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:14,代碼來源:utf_32.py

示例5: decode

# 需要導入模塊: import codecs [as 別名]
# 或者: from codecs import utf_32_ex_decode [as 別名]
def decode(self, input, errors='strict'):
        (object, consumed, byteorder) = \
            codecs.utf_32_ex_decode(input, errors, 0, False)
        if byteorder == -1:
            self.decode = codecs.utf_32_le_decode
        elif byteorder == 1:
            self.decode = codecs.utf_32_be_decode
        elif consumed>=4:
            raise UnicodeError("UTF-32 stream does not start with BOM")
        return (object, consumed)

### encodings module API 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:14,代碼來源:utf_32.py


注:本文中的codecs.utf_32_ex_decode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。