| 30 | #include <cstring> |
| 31 | |
| 32 | static int hexValue(char c) { |
| 33 | static char const digits[] = "0123456789ABCDEF"; |
| 34 | |
| 35 | if (c >= 'a' && c <= 'f') |
| 36 | c -= ('a' - 'A'); |
| 37 | |
| 38 | int value = std::find(digits, digits + 16, c) - digits; |
| 39 | if (value >= 16) { |
| 40 | throw std::runtime_error("hexValue"); |
| 41 | } |
| 42 | return value; |
| 43 | } |
| 44 | |
| 45 | // Does not handle "raw" form (e.g. #28C4D1), only escaped text |
| 46 | static std::string de4514(std::string const& input, int start, int& out_end) { |