Python codecs.code_page_decode() Examples
The following are 24
code examples of codecs.code_page_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 Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_incremental(self): decoded = codecs.code_page_decode(932, b'\x82', 'strict', False) self.assertEqual(decoded, ('', 0)) decoded = codecs.code_page_decode(932, b'\xe9\x80\xe9', 'strict', False) self.assertEqual(decoded, ('\u9a3e', 2)) decoded = codecs.code_page_decode(932, b'\xe9\x80\xe9\x80', 'strict', False) self.assertEqual(decoded, ('\u9a3e\u9a3e', 4)) decoded = codecs.code_page_decode(932, b'abc', 'strict', False) self.assertEqual(decoded, ('abc', 3))
Example #2
Source File: test_codecs.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def check_decode(self, cp, tests): for raw, errors, expected in tests: if expected is not None: try: decoded = codecs.code_page_decode(cp, raw, errors, True) except UnicodeDecodeError as err: self.fail('Unable to decode %a from "cp%s" with ' 'errors=%r: %s' % (raw, cp, errors, err)) self.assertEqual(decoded[0], expected, '%a.decode("cp%s", %r)=%a != %a' % (raw, cp, errors, decoded[0], expected)) # assert 0 <= decoded[1] <= len(raw) self.assertGreaterEqual(decoded[1], 0) self.assertLessEqual(decoded[1], len(raw)) else: self.assertRaises(UnicodeDecodeError, codecs.code_page_decode, cp, raw, errors, True)
Example #3
Source File: test_codecs.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_incremental(self): decoded = codecs.code_page_decode(932, b'\x82', 'strict', False) self.assertEqual(decoded, ('', 0)) decoded = codecs.code_page_decode(932, b'\xe9\x80\xe9', 'strict', False) self.assertEqual(decoded, ('\u9a3e', 2)) decoded = codecs.code_page_decode(932, b'\xe9\x80\xe9\x80', 'strict', False) self.assertEqual(decoded, ('\u9a3e\u9a3e', 4)) decoded = codecs.code_page_decode(932, b'abc', 'strict', False) self.assertEqual(decoded, ('abc', 3))
Example #4
Source File: test_codecs.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def check_decode(self, cp, tests): for raw, errors, expected in tests: if expected is not None: try: decoded = codecs.code_page_decode(cp, raw, errors, True) except UnicodeDecodeError as err: self.fail('Unable to decode %a from "cp%s" with ' 'errors=%r: %s' % (raw, cp, errors, err)) self.assertEqual(decoded[0], expected, '%a.decode("cp%s", %r)=%a != %a' % (raw, cp, errors, decoded[0], expected)) # assert 0 <= decoded[1] <= len(raw) self.assertGreaterEqual(decoded[1], 0) self.assertLessEqual(decoded[1], len(raw)) else: self.assertRaises(UnicodeDecodeError, codecs.code_page_decode, cp, raw, errors, True)
Example #5
Source File: test_codecs.py From ironpython3 with Apache License 2.0 | 6 votes |
def check_decode(self, cp, tests): for raw, errors, expected in tests: if expected is not None: try: decoded = codecs.code_page_decode(cp, raw, errors) except UnicodeDecodeError as err: self.fail('Unable to decode %a from "cp%s" with ' 'errors=%r: %s' % (raw, cp, errors, err)) self.assertEqual(decoded[0], expected, '%a.decode("cp%s", %r)=%a != %a' % (raw, cp, errors, decoded[0], expected)) # assert 0 <= decoded[1] <= len(raw) self.assertGreaterEqual(decoded[1], 0) self.assertLessEqual(decoded[1], len(raw)) else: self.assertRaises(UnicodeDecodeError, codecs.code_page_decode, cp, raw, errors)
Example #6
Source File: test_codecs.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_incremental(self): decoded = codecs.code_page_decode(932, b'\x82', 'strict', False) self.assertEqual(decoded, ('', 0)) decoded = codecs.code_page_decode(932, b'\xe9\x80\xe9', 'strict', False) self.assertEqual(decoded, ('\u9a3e', 2)) decoded = codecs.code_page_decode(932, b'\xe9\x80\xe9\x80', 'strict', False) self.assertEqual(decoded, ('\u9a3e\u9a3e', 4)) decoded = codecs.code_page_decode(932, b'abc', 'strict', False) self.assertEqual(decoded, ('abc', 3))
Example #7
Source File: cp65001.py From android_universal with MIT License | 5 votes |
def decode(input, errors='strict'): return codecs.code_page_decode(65001, input, errors, True)
Example #8
Source File: cp65001.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def decode(input, errors='strict'): return codecs.code_page_decode(65001, input, errors, True)
Example #9
Source File: cp65001.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def decode(input, errors='strict'): return codecs.code_page_decode(65001, input, errors, True)
Example #10
Source File: cp65001.py From odoo13-x64 with GNU General Public License v3.0 | 5 votes |
def decode(input, errors='strict'): return codecs.code_page_decode(65001, 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 |
def test_code_page_name(self): self.assertRaisesRegex(UnicodeEncodeError, 'cp932', codecs.code_page_encode, 932, '\xff') self.assertRaisesRegex(UnicodeDecodeError, 'cp932', codecs.code_page_decode, 932, b'\x81\x00', 'strict', True) self.assertRaisesRegex(UnicodeDecodeError, 'CP_UTF8', codecs.code_page_decode, self.CP_UTF8, b'\xff', 'strict', True)
Example #12
Source File: test_codecs.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_invalid_code_page(self): self.assertRaises(ValueError, codecs.code_page_encode, -1, 'a') self.assertRaises(ValueError, codecs.code_page_decode, -1, b'a') self.assertRaises(OSError, codecs.code_page_encode, 123, 'a') self.assertRaises(OSError, codecs.code_page_decode, 123, b'a')
Example #13
Source File: cp65001.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def decode(input, errors='strict'): return codecs.code_page_decode(65001, input, errors, True)
Example #14
Source File: cp65001.py From python2017 with MIT License | 5 votes |
def decode(input, errors='strict'): return codecs.code_page_decode(65001, input, errors, True)
Example #15
Source File: cp65001.py From python with Apache License 2.0 | 5 votes |
def decode(input, errors='strict'): return codecs.code_page_decode(65001, input, errors, True)
Example #16
Source File: test_codecs.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_code_page_decode(self): # Sanity self.assertEqual(codecs.code_page_decode(1252, b"aaaa"), ("aaaa", 4)) self.assertEqual(codecs.code_page_decode(1252, array.array('I', (1633771873,))), ("aaaa", 4)) self.assertRaises(TypeError, codecs.code_page_decode, "abc") self.assertRaises(TypeError, codecs.code_page_decode, None) self.assertRaises(TypeError, codecs.code_page_decode, None, None)
Example #17
Source File: test_codecs.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_code_page_name(self): self.assertRaisesRegex(UnicodeEncodeError, 'cp932', codecs.code_page_encode, 932, '\xff') self.assertRaisesRegex(UnicodeDecodeError, 'cp932', codecs.code_page_decode, 932, b'\x81\x00') self.assertRaisesRegex(UnicodeDecodeError, 'CP_UTF8', codecs.code_page_decode, self.CP_UTF8, b'\xff')
Example #18
Source File: test_codecs.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_invalid_code_page(self): self.assertRaises(ValueError, codecs.code_page_encode, -1, 'a') self.assertRaises(ValueError, codecs.code_page_decode, -1, b'a') self.assertRaises(OSError, codecs.code_page_encode, 123, 'a') self.assertRaises(OSError, codecs.code_page_decode, 123, b'a')
Example #19
Source File: cp65001.py From scylla with Apache License 2.0 | 5 votes |
def decode(input, errors='strict'): return codecs.code_page_decode(65001, input, errors, True)
Example #20
Source File: cp65001.py From Imogen with MIT License | 5 votes |
def decode(input, errors='strict'): return codecs.code_page_decode(65001, input, errors, True)
Example #21
Source File: test_codecs.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_code_page_name(self): self.assertRaisesRegex(UnicodeEncodeError, 'cp932', codecs.code_page_encode, 932, '\xff') self.assertRaisesRegex(UnicodeDecodeError, 'cp932', codecs.code_page_decode, 932, b'\x81\x00', 'strict', True) self.assertRaisesRegex(UnicodeDecodeError, 'CP_UTF8', codecs.code_page_decode, self.CP_UTF8, b'\xff', 'strict', True)
Example #22
Source File: test_codecs.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_invalid_code_page(self): self.assertRaises(ValueError, codecs.code_page_encode, -1, 'a') self.assertRaises(ValueError, codecs.code_page_decode, -1, b'a') self.assertRaises(OSError, codecs.code_page_encode, 123, 'a') self.assertRaises(OSError, codecs.code_page_decode, 123, b'a')
Example #23
Source File: cp65001.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def decode(input, errors='strict'): return codecs.code_page_decode(65001, input, errors, True)
Example #24
Source File: cp65001.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def decode(input, errors='strict'): return codecs.code_page_decode(65001, input, errors, True)