我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用codecs.raw_unicode_escape_encode()。
def encode(self, input, final=False): return codecs.raw_unicode_escape_encode(input, self.errors)[0]
def test_empty(self): self.assertEqual(codecs.raw_unicode_escape_encode(u""), ("", 0)) self.assertEqual(codecs.raw_unicode_escape_decode(""), (u"", 0))
def test_raw_encode(self): encode = codecs.raw_unicode_escape_encode for b in range(256): self.assertEqual(encode(unichr(b)), (chr(b), 1))
def test_escape_encode(self): encode = codecs.raw_unicode_escape_encode check = coding_checker(self, encode) for b in range(256): if chr(b) not in 'uU': check(u'\\' + unichr(b), '\\' + chr(b)) check(u'\u20ac', r'\u20ac') check(u'\U0001d120', r'\U0001d120')
def test_empty(self): self.assertEqual(codecs.raw_unicode_escape_encode(""), (b"", 0)) self.assertEqual(codecs.raw_unicode_escape_decode(b""), ("", 0))
def test_raw_encode(self): encode = codecs.raw_unicode_escape_encode for b in range(256): self.assertEqual(encode(chr(b)), (bytes([b]), 1))
def test_escape_encode(self): encode = codecs.raw_unicode_escape_encode check = coding_checker(self, encode) for b in range(256): if b not in b'uU': check('\\' + chr(b), b'\\' + bytes([b])) check('\u20ac', br'\u20ac') check('\U0001d120', br'\U0001d120')