mistserver/lib/encode.h
Thulinma 66dc2dc0cb Encoding fixes:
- base64 library renamed to encode library
- Moved urlencode/urldecode functions from HTTP library to encode library
- Moved hex/unhex functions from HTTP library to encode library
- Added urldecode support to RTMP urls, fixing XSplit wildcard stream support
2016-04-14 12:03:40 +02:00

39 lines
1.1 KiB
C++

#pragma once
#include <string>
/// Namespace for character encoding functions and classes
namespace Encodings {
/// Holds base64 decoding and encoding functions.
class Base64 {
private:
static const std::string chars;
static inline bool is_base64(unsigned char c);
public:
static std::string encode(std::string const input);
static std::string decode(std::string const & encoded_string);
};
/// urlencoding and urldecoding functions
class URL {
public:
/// urldecodes std::string data, parsing out both %-encoded characters and +-encoded spaces.
static std::string decode(const std::string & in);
/// urlencodes std::string data, leaving only the characters A-Za-z0-9~!&()' alone.
static std::string encode(const std::string & c);
};
/// Hexadecimal-related functions
class Hex {
public:
/// Decodes a single hexadecimal character to integer, case-insensitive.
static inline int ord(char c){
return ((c&15) + (((c&64)>>6) | ((c&64)>>3)));
}
/// Encodes a single character as two hex digits in string form.
static std::string chr(char dec);
};
}