libfilezilla
Namespaces | Enumerations | Functions
encode.hpp File Reference

Functions to encode/decode strings. More...

#include "libfilezilla.hpp"
#include <string>
#include <vector>
Include dependency graph for encode.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 fz
 The namespace used by libfilezilla.
 

Enumerations

enum class  base64_type { standard , url }
 Alphabet variations for base64. More...
 
enum class  base32_type { standard , base32hex , locale_safe }
 Alphabet variations for base32. More...
 

Functions

template<typename Char >
int hex_char_to_int (Char c)
 Converts a hex digit to decimal int. More...
 
template<typename OutString = std::vector<uint8_t>>
OutString hex_decode (std::string_view const &in)
 
template<typename OutString = std::vector<uint8_t>>
OutString hex_decode (std::wstring_view const &in)
 
template<typename Char = char, bool Lowercase = true>
Char int_to_hex_char (int d)
 Converts an integer to the corresponding lowercase hex digit. More...
 
template<typename String , typename InString , bool Lowercase = true>
String hex_encode (InString const &data)
 
std::string base64_encode (std::string_view const &in, base64_type type=base64_type::standard, bool pad=true)
 Encodes raw input string to base64.
 
std::string base64_encode (std::vector< uint8_t > const &in, base64_type type=base64_type::standard, bool pad=true)
 
std::string base64_encode (fz::buffer const &in, base64_type type=base64_type::standard, bool pad=true)
 
void base64_encode_append (std::string &result, std::string_view const &in, base64_type type=base64_type::standard, bool pad=true)
 base64-encodes input and appends it to result. More...
 
std::vector< uint8_t > base64_decode (std::string_view const &in)
 Decodes base64, ignores whitespace. Returns empty string on invalid input. More...
 
std::vector< uint8_t > base64_decode (std::wstring_view const &in)
 
std::vector< uint8_t > base64_decode (fz::buffer const &in)
 
std::string base64_decode_s (std::string_view const &in)
 
std::string base64_decode_s (std::wstring_view const &in)
 
std::string base64_decode_s (fz::buffer const &in)
 
std::string base32_encode (std::string_view const &in, base32_type type=base32_type::standard, bool pad=true)
 Encodes raw input string to base32.
 
std::string base32_encode (std::vector< uint8_t > const &in, base32_type type=base32_type::standard, bool pad=true)
 
std::string base32_encode (fz::buffer const &in, base32_type type=base32_type::standard, bool pad=true)
 
std::vector< uint8_t > base32_decode (std::string_view const &in, base32_type type=base32_type::standard)
 Decodes base32, ignores whitespace. Returns empty string on invalid input. More...
 
std::vector< uint8_t > base32_decode (std::wstring_view const &in, base32_type type=base32_type::standard)
 
std::vector< uint8_t > base32_decode (fz::buffer const &in, base32_type type=base32_type::standard)
 
std::string base32_decode_s (std::string_view const &in, base32_type type=base32_type::standard)
 
std::string base32_decode_s (std::wstring_view const &in, base32_type type=base32_type::standard)
 
std::string base32_decode_s (fz::buffer const &in, base32_type type=base32_type::standard)
 
std::string percent_encode (std::string_view const &s, bool keep_slashes=false)
 Percent-encodes string. More...
 
std::string percent_encode (std::wstring_view const &s, bool keep_slashes=false)
 
std::wstring percent_encode_w (std::wstring_view const &s, bool keep_slashes=false)
 Percent-encodes wide-character. Non-ASCII characters are converted to UTF-8 before they are encoded. More...
 
std::vector< uint8_t > percent_decode (std::string_view const &s, bool allow_embedded_null=false)
 Percent-decodes string. More...
 
std::vector< uint8_t > percent_decode (std::wstring_view const &s, bool allow_embedded_null=false)
 
std::string percent_decode_s (std::string_view const &s, bool allow_embedded_null=false)
 
std::string percent_decode_s (std::wstring_view const &s, bool allow_embedded_null=false)
 

Detailed Description

Functions to encode/decode strings.

Defines functions to deal with hex, base64 and percent encoding.