Fix compilation with GCC

This commit is contained in:
blankie 2023-05-02 15:29:37 +07:00
parent 2ecfe10584
commit b8de1cbb68
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 7 additions and 7 deletions

View File

@ -189,20 +189,20 @@ static inline void hexencode(char c, char out[2]) {
char nibble1 = (c >> 4) & 0xF;
char nibble2 = c & 0xF;
auto hexencode = [](char nibble) -> char {
return nibble < 10
auto hexencode = [](char nibble) {
return static_cast<char>(nibble < 10
? '0' + nibble
: 'A' + nibble - 10;
: 'A' + nibble - 10);
};
out[0] = hexencode(nibble1);
out[1] = hexencode(nibble2);
}
static inline char hexdecode(char nibble1, char nibble2) {
auto hexdecode = [](char nibble) -> char {
if (nibble >= '0' && nibble <= '9') return nibble - '0';
if (nibble >= 'A' && nibble <= 'F') return nibble - 'A' + 10;
if (nibble >= 'a' && nibble <= 'f') return nibble - 'a' + 10;
auto hexdecode = [](char nibble) {
if (nibble >= '0' && nibble <= '9') return static_cast<char>(nibble - '0');
if (nibble >= 'A' && nibble <= 'F') return static_cast<char>(nibble - 'A' + 10);
if (nibble >= 'a' && nibble <= 'f') return static_cast<char>(nibble - 'a' + 10);
throw std::invalid_argument("Invalid percent-encoded nibble received");
};