extmod: Add ubinascii.unhexlify

This also pulls out hex_digit from py/lexer.c and makes unichar_hex_digit
This commit is contained in:
Dave Hylands
2015-05-18 14:41:25 -07:00
committed by Damien George
parent 97ce883217
commit 3ad94d6072
7 changed files with 59 additions and 12 deletions

View File

@@ -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;
}