Add Url/Html encoding, ISO-8601 interval parse, TempFile, random_string charset

Universal additions (all generic, header-only, tested; full suite 1127 pass):
- Void::Encoding::Url — RFC 3986 percent encode/decode + query_encode.
- Void::Text::html_unescape — numeric + common named HTML entities -> UTF-8.
- Void::Time::parse_iso8601_interval — parse PT#H#M#S / P#DT#H#M#S durations
  (distinct from the unit-suffix parse_duration).
- Void::FileSystem::TempFile — RAII unique temp file (alongside TempDir),
  with keep() to persist.
- Void::Random::random_string(n, charset) overload.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 4.8 committed 2026-06-22 16:15:01 +03:00
1 parent 80293ee56f
commit fb0506581f
9 files changed
+645 -6

No files matched your search

+14 -6
View File
@@ -134,6 +134,19 @@ inline void fill_random(std::span<std::byte> buf) noexcept
}
}
/// Generate a random string of length n drawn from `charset`.
[[nodiscard]] inline std::string random_string(std::size_t n,
std::string_view charset)
{
std::string s;
if (charset.empty()) return s;
s.reserve(n);
for (std::size_t i = 0; i < n; ++i) {
s += charset[uniform_int<std::size_t>(0, charset.size() - 1)];
}
return s;
}
/// Generate a random alphanumeric string of length n.
[[nodiscard]] inline std::string random_string(std::size_t n)
{
@@ -141,12 +154,7 @@ inline void fill_random(std::span<std::byte> buf) noexcept
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789";
std::string s;
s.reserve(n);
for (std::size_t i = 0; i < n; ++i) {
s += chars[uniform_int<std::size_t>(0, chars.size() - 1)];
}
return s;
return random_string(n, chars);
}
/// Sample k distinct indices from [0, n).