MCPcopy Index your code
hub / github.com/python/cpython / unhex

Function unhex

Lib/quopri.py:170–184  ·  view source on GitHub ↗

Get the integer value of a hexadecimal number.

(s)

Source from the content-addressed store, hash-verified

168 return b'0' <= c <= b'9' or b'a' <= c <= b'f' or b'A' <= c <= b'F'
169
170def unhex(s):
171 """Get the integer value of a hexadecimal number."""
172 bits = 0
173 for c in s:
174 c = bytes((c,))
175 if b'0' <= c <= b'9':
176 i = ord('0')
177 elif b'a' <= c <= b'f':
178 i = ord('a')-10
179 elif b'A' <= c <= b'F':
180 i = ord(b'A')-10
181 else:
182 assert False, "non-hex digit "+repr(c)
183 bits = bits*16 + (ord(c) - i)
184 return bits
185
186
187

Callers 1

decodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…