import _testcapi def fmt(text, byte): uni = "U+%04x, " % ord(text) if text else "" return "%r (%s%02x)" % (text, uni, byte) for ch in range(256): up_byte, low_byte, ch_str, up_str, low_str = _testcapi.victor(ch) text = "equal" if up_byte == low_byte == ch else "NOT EQUAL" print("%s: upper=%s, lower=%s: %s" % (fmt(ch_str, ch), fmt(up_str, up_byte), fmt(low_str, low_byte), text)) print() latin1 = True for ch in range(256): up_byte, low_byte, ch_str, up_str, low_str = _testcapi.victor(ch) dec = bytes((ch,)).decode('latin1') if ch_str != dec: latin1 = False break print("LC_CTYPE uses Latin1 encoding?", latin1)