summaryrefslogtreecommitdiffstatshomepage
path: root/py/unicode.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/unicode.c')
-rw-r--r--py/unicode.c10
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;
+}