Add case parameter to FormatArrayAsHex

Use upper case where needed for vanilla compatibility
This commit is contained in:
Jonathan G Rennison
2024-03-03 12:05:06 +00:00
parent 9d65fd9c2a
commit 1ba9806002
4 changed files with 10 additions and 6 deletions

View File

@@ -210,14 +210,18 @@ const char *str_fix_scc_encoded(char *str, const char *last)
* @param data Array to format
* @return Converted string.
*/
std::string FormatArrayAsHex(std::span<const byte> data)
std::string FormatArrayAsHex(std::span<const byte> data, bool upper_case)
{
std::string hex_output;
hex_output.resize(data.size() * 2);
char txt[3];
for (uint i = 0; i < data.size(); ++i) {
seprintf(txt, lastof(txt), "%02x", data[i]);
if (upper_case) {
seprintf(txt, lastof(txt), "%02X", data[i]);
} else {
seprintf(txt, lastof(txt), "%02x", data[i]);
}
hex_output[i * 2] = txt[0];
hex_output[(i * 2) + 1] = txt[1];
}