Every line of 'python char to int' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
86 def charToInt(char): 87 if char =="": 88 return 0 89 else: 90 return int(char)
352 def ToChar(byte): 353 """Convert a byte to a character 354 355 This is useful because in Python 2 bytes is an alias for str, but in 356 Python 3 they are separate types. This function converts an ASCII value to 357 a value with the appropriate type in either case. 358 359 Args: 360 byte: A byte or str value 361 """ 362 return chr(byte) if type(byte) != str else byte
143 def CChar(c): 144 return C_CHAR.get(c, c)
68 def charset_to_int(s, charset): 69 """ Turn a string into a non-negative integer. 70 71 >>> charset_to_int('0', B40_CHARS) 72 0 73 >>> charset_to_int('10', B40_CHARS) 74 40 75 >>> charset_to_int('abcd', B40_CHARS) 76 658093 77 >>> charset_to_int('', B40_CHARS) 78 0 79 >>> charset_to_int('muneeb.id', B40_CHARS) 80 149190078205533 81 >>> charset_to_int('A', B40_CHARS) 82 Traceback (most recent call last): 83 ... 84 ValueError: substring not found 85 """ 86 output = 0 87 for char in s: 88 output = output * len(charset) + charset.index(char) 89 90 return output
53 def unichar(i): 54 return chr(i)
14 def fourCharToInt(code): 15 return struct.unpack('>l', code)[0]
31 def convertCodeToInt(code): 32 if not code: 33 return None 34 if " " in code: 35 return tuple([convertCodeToInt(i) for i in code.split(" ")]) 36 return int(code, 16)
98 def int_to_chars(i): 99 parts = [] 100 while i: 101 i, ic = divmod(i, 10) 102 parts.append(convert_int(ic)) 103 parts = parts[::-1] 104 return [ 105 '.'.join(parts[p][l] for p in range(len(parts))) for l in range(7) 106 ]