Python codecs.utf_16_decode() Examples

The following are 30 code examples of codecs.utf_16_decode(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module codecs , or try the search function .
Example #1
Source File: test_codecs.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
def test_utf_16_decode(self):
        # When BOM present: it is removed and the proper UTF-16 variant is automatically selected
        string, num_processed = codecs.utf_16_decode(codecs.BOM_UTF16_LE + b'a\0b\0c\0')
        self.assertEqual(string, "abc")
        self.assertEqual(num_processed, 4 * 2)

        string, num_processed = codecs.utf_16_decode(codecs.BOM_UTF16_BE + b'\0a\0b\0c')
        self.assertEqual(string, "abc")
        self.assertEqual(num_processed, 4 * 2)

        # When no BOM: on little-endian systems, UTF-16 defaults to UTF-16-LE
        string, num_processed = codecs.utf_16_decode(b'a\0b\0c\0')
        self.assertEqual(string, 'abc')
        self.assertEqual(num_processed, 3 * 2)

        self.assertEqual(codecs.utf_16_decode(array.array('I', (1633771873,))), ("慡慡", 4))

        self.assertRaises(TypeError, codecs.utf_16_decode, "abc")
        self.assertRaises(TypeError, codecs.utf_16_decode, None)
        self.assertRaises(TypeError, codecs.utf_16_decode, None, None)
        self.assertEquals(codecs.utf_16_decode(b"", None), ("", 0)) 
Example #2
Source File: utf_16.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #3
Source File: utf_16.py    From ImageFusion with MIT License 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #4
Source File: utf_16.py    From python2017 with MIT License 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #5
Source File: test_codecs.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_handlers(self):
        self.assertEqual((u'\ufffd', 1),
                         codecs.utf_16_decode('\x01', 'replace', True))
        self.assertEqual((u'', 1),
                         codecs.utf_16_decode('\x01', 'ignore', True)) 
Example #6
Source File: test_codecs.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_errors(self):
        self.assertRaises(UnicodeDecodeError, codecs.utf_16_decode, "\xff", "strict", True) 
Example #7
Source File: utf_16.py    From datafari with Apache License 2.0 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #8
Source File: utf_16.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #9
Source File: utf_16.py    From PhonePi_SampleServer with MIT License 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #10
Source File: utf_16.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #11
Source File: test_codecs.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_handlers(self):
        self.assertEqual(('\ufffd', 1),
                         codecs.utf_16_decode(b'\x01', 'replace', True))
        self.assertEqual(('', 1),
                         codecs.utf_16_decode(b'\x01', 'ignore', True)) 
Example #12
Source File: test_codecs.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_errors(self):
        self.assertRaises(UnicodeDecodeError, codecs.utf_16_decode,
                          b"\xff", "strict", True) 
Example #13
Source File: utf_16.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #14
Source File: utf_16.py    From syntheticmass with Apache License 2.0 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #15
Source File: utf_16.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #16
Source File: utf_16.py    From ImageFusion with MIT License 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #17
Source File: utf_16.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #18
Source File: test_codecs.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_handlers(self):
        self.assertEqual((u'\ufffd', 1),
                         codecs.utf_16_decode('\x01', 'replace', True))
        self.assertEqual((u'', 1),
                         codecs.utf_16_decode('\x01', 'ignore', True)) 
Example #19
Source File: test_codecs.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_errors(self):
        self.assertRaises(UnicodeDecodeError, codecs.utf_16_decode, "\xff", "strict", True) 
Example #20
Source File: utf_16.py    From RevitBatchProcessor with GNU General Public License v3.0 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #21
Source File: utf_16.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #22
Source File: utf_16.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #23
Source File: utf_16.py    From unity-python with MIT License 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #24
Source File: utf_16.py    From android_universal with MIT License 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #25
Source File: utf_16.py    From canape with GNU General Public License v3.0 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #26
Source File: utf_16.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #27
Source File: utf_16.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True) 
Example #28
Source File: test_codecs.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_handlers(self):
        self.assertEqual((u'\ufffd', 1),
                         codecs.utf_16_decode('\x01', 'replace', True))
        self.assertEqual((u'', 1),
                         codecs.utf_16_decode('\x01', 'ignore', True)) 
Example #29
Source File: test_codecs.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_errors(self):
        self.assertRaises(UnicodeDecodeError, codecs.utf_16_decode, "\xff", "strict", True) 
Example #30
Source File: utf_16.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def decode(input, errors='strict'):
    return codecs.utf_16_decode(input, errors, True)