Skip to content

Commit d5360b8

Browse files
committed
Fix conversion to hex of negative characters
Negative characters were previously converted with unneccessary leading `f` characters. For example `-1` or `0xff` characters were previously printed as `_ffffffff`. This commit uses the value of characters in the -128 to -1 range remapped into the 128 to 255 range, so that `-1` prints as `_ff`, without unneccessary padding with leading `f`s.
1 parent f7c3a4b commit d5360b8

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/util/string_utils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ std::string escape_non_alnum(const std::string &to_escape)
163163
else if(isalnum(uch))
164164
escaped << ch;
165165
else
166-
escaped << '_' << std::hex << std::setfill('0') << std::setw(2)
167-
<< (unsigned int)ch;
166+
escaped << '_' << std::hex << std::setfill('0') << std::setw(2) << uch;
168167
}
169168
return escaped.str();
170169
}

0 commit comments

Comments
 (0)