summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2017-03-27 15:37:25 +0100
committerMichael Drake <michael.drake@codethink.co.uk>2017-03-27 15:37:25 +0100
commit0e7ebb4ee01904c746fe948f9343fd3418e735ae (patch)
treee03acf41e56d04aae132c4b202e5353153074514
parentb14aa97a2a25cc0bcd258216aef7c70f9d354f1e (diff)
downloadnetsurf-0e7ebb4ee01904c746fe948f9343fd3418e735ae.tar.gz
netsurf-0e7ebb4ee01904c746fe948f9343fd3418e735ae.tar.bz2
ASCII: Add function for converting two hex chars to value.
-rw-r--r--utils/ascii.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/utils/ascii.h b/utils/ascii.h
index e5f9949ff..94d988aed 100644
--- a/utils/ascii.h
+++ b/utils/ascii.h
@@ -188,6 +188,19 @@ static inline int ascii_hex_to_value(char c)
}
/**
+ * Converts two hexadecimal characters to a single number
+ *
+ * \param[in] c1 most significant hex digit.
+ * \param[in] c2 least significant hex digit.
+ * \return the total value of the two digit hex number (0-255),
+ * or -ve if input not hex.
+ */
+static inline int ascii_hex_to_value_2_chars(char c1, char c2)
+{
+ return 16 * ascii_hex_to_value(c1) + ascii_hex_to_value(c2);
+}
+
+/**
* Convert an upper case character to lower case.
*
* If the given character is not upper case alphabetical, it is returned