From 0a903e69fbd9b19d8d8da0593f31dec5807af566 Mon Sep 17 00:00:00 2001 From: Kahrl Date: Thu, 29 Aug 2013 05:56:48 +0200 Subject: Implement urlencode and urldecode --- src/hex.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/hex.h') diff --git a/src/hex.h b/src/hex.h index 87a6aecb4..6f00a79bf 100644 --- a/src/hex.h +++ b/src/hex.h @@ -46,4 +46,17 @@ static inline std::string hex_encode(const std::string &data) return hex_encode(data.c_str(), data.size()); } +static inline bool hex_digit_decode(char hexdigit, unsigned char &value) +{ + if(hexdigit >= '0' && hexdigit <= '9') + value = hexdigit - '0'; + else if(hexdigit >= 'A' && hexdigit <= 'F') + value = hexdigit - 'A' + 10; + else if(hexdigit >= 'a' && hexdigit <= 'f') + value = hexdigit - 'a' + 10; + else + return false; + return true; +} + #endif -- cgit v1.2.3