1#ifndef LIBFILEZILLA_ENCODE_HEADER
2#define LIBFILEZILLA_ENCODE_HEADER
24template<
typename Char>
27 if (
c >=
'a' &&
c <=
'f') {
30 if (
c >=
'A' &&
c <=
'F') {
33 else if (
c >=
'0' &&
c <=
'9') {
40template<
typename OutString,
typename String>
44 if (!(
in.size() % 2)) {
45 ret.reserve(
in.size() / 2);
46 for (
size_t i = 0;
i <
in.size();
i += 2) {
59template<
typename OutString = std::vector<u
int8_t>>
65template<
typename OutString = std::vector<u
int8_t>>
77template<
typename Char =
char,
bool Lowercase = true>
84 return static_cast<Char>(
'0' +
d);
88template<
typename String,
typename InString,
bool Lowercase = true>
91 static_assert(
sizeof(
typename InString::value_type) == 1,
"Input must be a container of 8 bit values");
93 ret.reserve(data.size() * 2);
94 for (
auto const&
c : data) {
The buffer class is a simple buffer where data can be appended at the end and consumed at the front....
Definition buffer.hpp:27
Small class to return filesystem errors.
Definition fsresult.hpp:26
Sets some global macros and further includes string.hpp.
The namespace used by libfilezilla.
Definition apply.hpp:17
std::vector< uint8_t > percent_decode(std::string_view const &s, bool allow_embedded_null=false)
Percent-decodes string.
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.
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.
std::vector< uint8_t > base64_decode(std::string_view const &in)
Decodes base64, ignores whitespace. Returns empty string on invalid input.
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.
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 base32_encode(std::string_view const &in, base32_type type=base32_type::standard, bool pad=true)
Encodes raw input string to base32.
Char int_to_hex_char(int d)
Converts an integer to the corresponding lowercase hex digit.
Definition encode.hpp:78
base32_type
Alphabet variations for base32.
Definition encode.hpp:145
bool dispatch(event_base const &ev, F &&f)
Dispatch for simple_event<> based events to simple functors.
Definition event_handler.hpp:199
std::string percent_encode(std::string_view const &s, bool keep_slashes=false)
Percent-encodes string.
base64_type
Alphabet variations for base64.
Definition encode.hpp:108
int hex_char_to_int(Char c)
Converts a hex digit to decimal int.
Definition encode.hpp:25