Python codecs.raw_unicode_escape_decode() Examples
The following are 30
code examples of codecs.raw_unicode_escape_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 Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_unicode_escape(self): # Escape-decoding an unicode string is supported ang gives the same # result as decoding the equivalent ASCII bytes string. self.assertEqual(codecs.unicode_escape_decode(r"\u1234"), ("\u1234", 6)) self.assertEqual(codecs.unicode_escape_decode(br"\u1234"), ("\u1234", 6)) self.assertEqual(codecs.raw_unicode_escape_decode(r"\u1234"), ("\u1234", 6)) self.assertEqual(codecs.raw_unicode_escape_decode(br"\u1234"), ("\u1234", 6)) self.assertRaises(UnicodeDecodeError, codecs.unicode_escape_decode, br"\U00110000") self.assertEqual(codecs.unicode_escape_decode(r"\U00110000", "replace"), ("\ufffd", 10)) self.assertEqual(codecs.unicode_escape_decode(r"\U00110000", "backslashreplace"), (r"\x5c\x55\x30\x30\x31\x31\x30\x30\x30\x30", 10)) self.assertRaises(UnicodeDecodeError, codecs.raw_unicode_escape_decode, br"\U00110000") self.assertEqual(codecs.raw_unicode_escape_decode(r"\U00110000", "replace"), ("\ufffd", 10)) self.assertEqual(codecs.raw_unicode_escape_decode(r"\U00110000", "backslashreplace"), (r"\x5c\x55\x30\x30\x31\x31\x30\x30\x30\x30", 10))
Example #2
Source File: test_codecs.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_unicode_escape(self): # Escape-decoding a unicode string is supported and gives the same # result as decoding the equivalent ASCII bytes string. self.assertEqual(codecs.unicode_escape_decode(r"\u1234"), ("\u1234", 6)) self.assertEqual(codecs.unicode_escape_decode(br"\u1234"), ("\u1234", 6)) self.assertEqual(codecs.raw_unicode_escape_decode(r"\u1234"), ("\u1234", 6)) self.assertEqual(codecs.raw_unicode_escape_decode(br"\u1234"), ("\u1234", 6)) self.assertRaises(UnicodeDecodeError, codecs.unicode_escape_decode, br"\U00110000") self.assertEqual(codecs.unicode_escape_decode(r"\U00110000", "replace"), ("\ufffd", 10)) self.assertEqual(codecs.unicode_escape_decode(r"\U00110000", "backslashreplace"), (r"\x5c\x55\x30\x30\x31\x31\x30\x30\x30\x30", 10)) self.assertRaises(UnicodeDecodeError, codecs.raw_unicode_escape_decode, br"\U00110000") self.assertEqual(codecs.raw_unicode_escape_decode(r"\U00110000", "replace"), ("\ufffd", 10)) self.assertEqual(codecs.raw_unicode_escape_decode(r"\U00110000", "backslashreplace"), (r"\x5c\x55\x30\x30\x31\x31\x30\x30\x30\x30", 10))
Example #3
Source File: raw_unicode_escape.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #4
Source File: raw_unicode_escape.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #5
Source File: raw_unicode_escape.py From medicare-demo with Apache License 2.0 | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #6
Source File: test_codecs.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_escape_decode(self): decode = codecs.raw_unicode_escape_decode check = coding_checker(self, decode) for b in range(256): if b not in b'uU': check(b'\\' + bytes([b]), '\\' + chr(b)) check(br"\u20ac", "\u20ac") check(br"\U0001d120", "\U0001d120")
Example #7
Source File: test_codecs.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_raw_decode(self): decode = codecs.raw_unicode_escape_decode for b in range(256): self.assertEqual(decode(bytes([b]) + b'0'), (chr(b) + '0', 2))
Example #8
Source File: raw_unicode_escape.py From syntheticmass with Apache License 2.0 | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #9
Source File: raw_unicode_escape.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #10
Source File: raw_unicode_escape.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #11
Source File: raw_unicode_escape.py From unity-python with MIT License | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #12
Source File: raw_unicode_escape.py From android_universal with MIT License | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #13
Source File: raw_unicode_escape.py From canape with GNU General Public License v3.0 | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #14
Source File: raw_unicode_escape.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #15
Source File: raw_unicode_escape.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #16
Source File: raw_unicode_escape.py From RevitBatchProcessor with GNU General Public License v3.0 | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #17
Source File: test_codecs.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_empty(self): self.assertEqual(codecs.raw_unicode_escape_encode(""), (b"", 0)) self.assertEqual(codecs.raw_unicode_escape_decode(b""), ("", 0))
Example #18
Source File: raw_unicode_escape.py From PhonePi_SampleServer with MIT License | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #19
Source File: raw_unicode_escape.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #20
Source File: raw_unicode_escape.py From datafari with Apache License 2.0 | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #21
Source File: test_codecs.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_decode_errors(self): decode = codecs.raw_unicode_escape_decode for c, d in ('u', 4), ('U', 4): for i in range(d): self.assertRaises(UnicodeDecodeError, decode, "\\" + c + "0"*i) self.assertRaises(UnicodeDecodeError, decode, "[\\" + c + "0"*i + "]") data = "[\\" + c + "0"*i + "]\\" + c + "0"*i self.assertEqual(decode(data, "ignore"), (u"[]", len(data))) self.assertEqual(decode(data, "replace"), (u"[\ufffd]\ufffd", len(data))) self.assertRaises(UnicodeDecodeError, decode, r"\U00110000") self.assertEqual(decode(r"\U00110000", "ignore"), (u"", 10)) self.assertEqual(decode(r"\U00110000", "replace"), (u"\ufffd", 10))
Example #22
Source File: test_codecs.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_escape_decode(self): decode = codecs.raw_unicode_escape_decode check = coding_checker(self, decode) for b in range(256): if chr(b) not in 'uU': check('\\' + chr(b), u'\\' + unichr(b)) check(r"\u20ac", u"\u20ac") check(r"\U0001d120", u"\U0001d120")
Example #23
Source File: test_codecs.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_raw_decode(self): decode = codecs.raw_unicode_escape_decode for b in range(256): self.assertEqual(decode(chr(b) + '0'), (unichr(b) + u'0', 2))
Example #24
Source File: test_codecs.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_empty(self): self.assertEqual(codecs.raw_unicode_escape_encode(u""), ("", 0)) self.assertEqual(codecs.raw_unicode_escape_decode(""), (u"", 0))
Example #25
Source File: raw_unicode_escape.py From python2017 with MIT License | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #26
Source File: raw_unicode_escape.py From ImageFusion with MIT License | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #27
Source File: raw_unicode_escape.py From ImageFusion with MIT License | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #28
Source File: raw_unicode_escape.py From python with Apache License 2.0 | 5 votes |
def decode(self, input, final=False): return codecs.raw_unicode_escape_decode(input, self.errors)[0]
Example #29
Source File: test_codecs.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_escape_decode(self): decode = codecs.raw_unicode_escape_decode check = coding_checker(self, decode) for b in range(256): if b not in b'uU': check(b'\\' + bytes([b]), '\\' + chr(b)) check(br"\u20ac", "\u20ac") check(br"\U0001d120", "\U0001d120")
Example #30
Source File: test_codecs.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_raw_decode(self): decode = codecs.raw_unicode_escape_decode for b in range(256): self.assertEqual(decode(bytes([b]) + b'0'), (chr(b) + '0', 2))