4 * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5 * See included license file for license details.
10 bool isHexDigit(char c)
12 return isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
15 //! \return The integer equivalent to \a c.
16 //! \retval -1 The character \a c is not a hex character.
17 uint8_t hexCharToInt(char c)
19 if (c >= '0' && c <= '9')
21 else if (c >= 'a' && c <= 'f')
23 else if (c >= 'A' && c <= 'F')
26 return static_cast<uint8_t>(-1);
29 //! \param encodedByte Must point to at least two ASCII hex characters.
31 uint8_t hexByteToInt(const char * encodedByte)
33 return (hexCharToInt(encodedByte[0]) << 4) | hexCharToInt(encodedByte[1]);