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
This commit is contained in:
parent
15603bc053
commit
66dc2dc0cb
9 changed files with 197 additions and 174 deletions
39
lib/encode.h
Normal file
39
lib/encode.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
#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);
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue