Changeset View
Changeset View
Standalone View
Standalone View
src/util/strencodings.cpp
Show First 20 Lines • Show All 642 Lines • ▼ Show 20 Lines | |||||
std::string Capitalize(std::string str) { | std::string Capitalize(std::string str) { | ||||
if (str.empty()) { | if (str.empty()) { | ||||
return str; | return str; | ||||
} | } | ||||
str[0] = ToUpper(str.front()); | str[0] = ToUpper(str.front()); | ||||
return str; | return str; | ||||
} | } | ||||
std::string HexStr(const Span<const uint8_t> s) { | |||||
std::string rv; | |||||
static constexpr char hexmap[16] = {'0', '1', '2', '3', '4', '5', '6', '7', | |||||
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; | |||||
rv.reserve(s.size() * 2); | |||||
for (uint8_t v : s) { | |||||
rv.push_back(hexmap[v >> 4]); | |||||
rv.push_back(hexmap[v & 15]); | |||||
} | |||||
return rv; | |||||
} |