38constexpr std::string_view safe_chars =
42 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
44 "abcdefghijklmnopqrstuvwxyz"
48constexpr std::size_t num_8bit_chars = 256;
55[[nodiscard]]
constexpr auto create_safe_char_table()
56 -> std::array<bool, num_8bit_chars> {
57 std::array<bool, num_8bit_chars> table{};
58 for (std::size_t i = 0; i < num_8bit_chars; ++i) {
61 for (
const char c : safe_chars) {
62 table[
static_cast<std::uint8_t
>(c)] =
true;
74[[nodiscard]]
auto is_safe_char(
char c) ->
bool {
75 static constexpr auto table = create_safe_char_table();
76 return table[
static_cast<std::uint8_t
>(c)];
83 for (
const char c : input.str()) {
84 if (!is_safe_char(c)) {
85 output.push_back(
'%');
86 constexpr std::string_view hex_chars =
"0123456789ABCDEF";
88 static_cast<unsigned>(
static_cast<std::uint8_t
>(c));
89 constexpr unsigned mask = 0xFU;
90 output.push_back(hex_chars[(
byte >> 4U) & mask]);
91 output.push_back(hex_chars[
byte & mask]);
Class of UTF-8 encoded string.
Declaration of escape_for_file_name function.
Namespace of utility functions and classes.
auto escape_for_file_name(const Utf8String &input) -> Utf8String
Escape a string for a file name.
Namespace of stat_bench source codes.