Exemplo n.º 1
0
 def testlossy0xed(self):
     encoding.encoding = b'euc-kr'  # U+Dxxx Hangul
     s = u'\ud1bc\xc0'.encode('utf-8')
     l = encoding.tolocal(s)
     self.assertIn(b'\xed', l)
     self.assertTrue(l.endswith(b'?'))  # lossy
     self.assertEqual(s, encoding.toutf8b(l))  # utf8 sequence preserved
Exemplo n.º 2
0
 def testlossless0xed(self):
     encoding.encoding = b'euc-kr'  # U+Dxxx Hangul
     s = u'\ud1bc'.encode('utf-8')
     l = encoding.tolocal(s)
     self.assertEqual(l, b'\xc5\xed')  # lossless
     self.assertEqual(s, encoding.toutf8b(l))  # convert back to utf-8
Exemplo n.º 3
0
 def testlossylatin(self):
     encoding.encoding = b'ascii'
     s = u'\xc0'.encode('utf-8')
     l = encoding.tolocal(s)
     self.assertEqual(l, b'?')  # lossy
     self.assertEqual(s, encoding.toutf8b(l))  # utf8 sequence preserved
Exemplo n.º 4
0
 def testlosslesslatin(self):
     encoding.encoding = b'latin-1'
     s = u'\xc0'.encode('utf-8')
     l = encoding.tolocal(s)
     self.assertEqual(l, b'\xc0')  # lossless
     self.assertEqual(s, encoding.toutf8b(l))  # convert back to utf-8
Exemplo n.º 5
0
 def testasciifastpath(self):
     s = b'\0' * 100
     self.assertTrue(s is encoding.toutf8b(s))
     self.assertTrue(s is encoding.fromutf8b(s))