Exemplo n.º 1
0
 def test_utf_32(self):
     assert encode_endian(u"\xe4", "utf-32", le=True) == \
         b"\xff\xfe\x00\x00\xe4\x00\x00\x00"
     assert encode_endian(u"\xe4", "utf-32-le") == b"\xe4\x00\x00\x00"
     assert encode_endian(u"\xe4", "utf-32",
                          le=False) == b"\x00\x00\xfe\xff\x00\x00\x00\xe4"
     assert encode_endian(u"\xe4", "utf-32-be") == b"\x00\x00\x00\xe4"
Exemplo n.º 2
0
 def test_utf_32(self):
     assert encode_endian(u"\xe4", "utf-32", le=True) == \
         b"\xff\xfe\x00\x00\xe4\x00\x00\x00"
     assert encode_endian(u"\xe4", "utf-32-le") == b"\xe4\x00\x00\x00"
     assert encode_endian(
         u"\xe4", "utf-32", le=False) == b"\x00\x00\xfe\xff\x00\x00\x00\xe4"
     assert encode_endian(u"\xe4", "utf-32-be") == b"\x00\x00\x00\xe4"
Exemplo n.º 3
0
 def test_other(self):
     assert encode_endian(u"\xe4", "latin-1") == b"\xe4"
     assert encode_endian(u"\xe4", "utf-8") == b"\xc3\xa4"
     with self.assertRaises(LookupError):
         encode_endian(u"", "nopenope")
     with self.assertRaises(UnicodeEncodeError):
         assert encode_endian(u"\u2714", "latin-1")
     assert encode_endian(u"\u2714", "latin-1", "replace") == b"?"
Exemplo n.º 4
0
 def test_other(self):
     assert encode_endian(u"\xe4", "latin-1") == b"\xe4"
     assert encode_endian(u"\xe4", "utf-8") == b"\xc3\xa4"
     with self.assertRaises(LookupError):
         encode_endian(u"", "nopenope")
     with self.assertRaises(UnicodeEncodeError):
         assert encode_endian(u"\u2714", "latin-1")
     assert encode_endian(u"\u2714", "latin-1", "replace") == b"?"
Exemplo n.º 5
0
 def test_utf_16(self):
     assert encode_endian(u"\xe4", "utf-16", le=True) == b"\xff\xfe\xe4\x00"
     assert encode_endian(u"\xe4", "utf-16-le") == b"\xe4\x00"
     assert encode_endian(u"\xe4", "utf-16",
                          le=False) == b"\xfe\xff\x00\xe4"
     assert encode_endian(u"\xe4", "utf-16-be") == b"\x00\xe4"
Exemplo n.º 6
0
 def test_utf_16(self):
     assert encode_endian(u"\xe4", "utf-16", le=True) == b"\xff\xfe\xe4\x00"
     assert encode_endian(u"\xe4", "utf-16-le") == b"\xe4\x00"
     assert encode_endian(
         u"\xe4", "utf-16", le=False) == b"\xfe\xff\x00\xe4"
     assert encode_endian(u"\xe4", "utf-16-be") == b"\x00\xe4"