def test_text_decode_utf16be(): encoder = TextEncoder() encoder.set_encoding(TextEncoder.E_utf16be) for c in valid_characters(): enc = c.encode('utf-16be') dec = encoder.decode_text(enc) assert len(c) == len(dec) assert c == dec
def test_text_decode_utf8(): encoder = TextEncoder() encoder.set_encoding(TextEncoder.E_utf8) for c in valid_characters(): enc = c.encode('utf-8') assert len(enc) <= 4 dec = encoder.decode_text(enc) assert len(dec) == 1 assert dec == c
def test_text_decode_iso8859(): encoder = TextEncoder() encoder.set_encoding(TextEncoder.E_iso8859) for i in xrange(255): enc = unichr(i).encode('latin-1') assert len(enc) == 1 dec = encoder.decode_text(enc) assert len(dec) == 1 assert ord(dec) == i