MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / unhex

Function unhex

tools/python-3.11.9-amd64/Lib/quopri.py:177–191  ·  view source on GitHub ↗

Get the integer value of a hexadecimal number.

(s)

Source from the content-addressed store, hash-verified

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

Callers 1

decodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected