1 """Constants and membership tests for ASCII characters"""
41 "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
42 "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
43 "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
44 "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US",
49 if type(c
) == type(""):
54 def isalnum(c
): return isalpha(c
) or isdigit(c
)
55 def isalpha(c
): return isupper(c
) or islower(c
)
56 def isascii(c
): return _ctoi(c
) <= 127 # ?
57 def isblank(c
): return _ctoi(c
) in (8,32)
58 def iscntrl(c
): return _ctoi(c
) <= 31
59 def isdigit(c
): return _ctoi(c
) >= 48 and _ctoi(c
) <= 57
60 def isgraph(c
): return _ctoi(c
) >= 33 and _ctoi(c
) <= 126
61 def islower(c
): return _ctoi(c
) >= 97 and _ctoi(c
) <= 122
62 def isprint(c
): return _ctoi(c
) >= 32 and _ctoi(c
) <= 126
63 def ispunct(c
): return _ctoi(c
) != 32 and not isalnum(c
)
64 def isspace(c
): return _ctoi(c
) in (9, 10, 11, 12, 13, 32)
65 def isupper(c
): return _ctoi(c
) >= 65 and _ctoi(c
) <= 90
66 def isxdigit(c
): return isdigit(c
) or \
67 (_ctoi(c
) >= 65 and _ctoi(c
) <= 70) or (_ctoi(c
) >= 97 and _ctoi(c
) <= 102)
68 def isctrl(c
): return _ctoi(c
) < 32
69 def ismeta(c
): return _ctoi(c
) > 127
72 if type(c
) == type(""):
73 return chr(_ctoi(c
) & 0x7f)
75 return _ctoi(c
) & 0x7f
78 if type(c
) == type(""):
79 return chr(_ctoi(c
) & 0x1f)
81 return _ctoi(c
) & 0x1f
84 if type(c
) == type(""):
85 return chr(_ctoi(c
) |
0x80)
87 return _ctoi(c
) |
0x80
94 rep
= chr((bits
& 0x7f) |
0x20)
96 rep
= "^" + chr(((bits
& 0x7f) |
0x20) + 0x20)