StringToHex now writes two digits per unsigned byte (an 8-letter Cyrillic name now takes 32 hex chars instead of 128)
This commit is contained in:
parent
84ca4208d2
commit
6c33829ccd
@ -330,15 +330,15 @@ inline RE::BSFixedString GetPlayerHash()
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline RE::BSFixedString StringToHex(RE::BSFixedString a_string)
|
// Two digits per byte, as the engine writes save names ("%.2X"). char is signed, so a byte
|
||||||
|
// above 0x7F (any UTF-8 non-ASCII character) must be widened as unsigned, or it prints as FFFFFFxx.
|
||||||
|
inline std::string StringToHex(std::string_view a_string)
|
||||||
{
|
{
|
||||||
std::string_view str(a_string);
|
std::string result;
|
||||||
|
result.reserve(a_string.size() * 2);
|
||||||
std::stringstream sstream;
|
for (const auto ch : a_string) {
|
||||||
for (auto ch : str) {
|
result += std::format("{:02X}", static_cast<std::uint8_t>(ch));
|
||||||
sstream << std::uppercase << std::hex << static_cast<int>(ch);
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
return sstream.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user