diff options
author | Dave Hylands <dhylands@gmail.com> | 2015-05-18 14:41:25 -0700 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-05-20 09:29:22 +0100 |
commit | 3ad94d6072555955a796c8c72a526c4fdff86711 (patch) | |
tree | c845f32926a12105b6929b422c3b66c55f098481 /py/unicode.c | |
parent | 97ce883217c646a2d2bc9bf6bfce6e2eaa731dae (diff) | |
download | micropython-3ad94d6072555955a796c8c72a526c4fdff86711.tar.gz micropython-3ad94d6072555955a796c8c72a526c4fdff86711.zip |
extmod: Add ubinascii.unhexlify
This also pulls out hex_digit from py/lexer.c and makes unichar_hex_digit
Diffstat (limited to 'py/unicode.c')
-rw-r--r-- | py/unicode.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/py/unicode.c b/py/unicode.c index db4aa438ac..63e9601185 100644 --- a/py/unicode.c +++ b/py/unicode.c @@ -169,3 +169,13 @@ unichar unichar_toupper(unichar c) { } return c; } + +mp_uint_t unichar_xdigit_value(unichar c) { + // c is assumed to be hex digit + mp_uint_t n = c - '0'; + if (n > 9) { + n &= ~('a' - 'A'); + n -= ('A' - ('9' + 1)); + } + return n; +} |