summaryrefslogtreecommitdiff
path: root/src/hex.h
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2013-08-29 05:56:48 +0200
committerKahrl <kahrl@gmx.net>2013-12-13 18:05:35 +0100
commit0a903e69fbd9b19d8d8da0593f31dec5807af566 (patch)
tree47ca583fc413a041a7e1161ff105a1a53b385f8d /src/hex.h
parent0404bbf67196e83d04620180e704916671371ca1 (diff)
downloadminetest-0a903e69fbd9b19d8d8da0593f31dec5807af566.tar.gz
minetest-0a903e69fbd9b19d8d8da0593f31dec5807af566.tar.bz2
minetest-0a903e69fbd9b19d8d8da0593f31dec5807af566.zip
Implement urlencode and urldecode
Diffstat (limited to 'src/hex.h')
-rw-r--r--src/hex.h13
1 files changed, 13 insertions, 0 deletions
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