mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Implement urlencode and urldecode
This commit is contained in:
parent
0404bbf671
commit
0a903e69fb
4 changed files with 57 additions and 6 deletions
13
src/hex.h
13
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue