Skip to content

Commit

Permalink
Fix std::cout printing char instead of int
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill-hbrhbr committed Aug 10, 2024
1 parent d6c73b4 commit 51bb3cc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/core/src/clp/ffi/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ auto validate_and_append_escaped_utf8_string(string_view src, string& dst) -> bo
auto const byte{static_cast<uint8_t>(*it)};
if (cLargestControlCharacter >= byte) {
std::stringstream ss;
ss << "\\u00" << std::hex << std::setw(2) << std::setfill('0') << byte;
// Add `+` in front of byte so that stringstream treat it as a char instead of
// a character (uint8_t is equivalent to unsigned char).
ss << "\\u00" << std::hex << std::setw(2) << std::setfill('0') << +byte;
escaped_char = {ss.str().substr(0, cControlCharacterMaxSize)};
} else {
escape_required = false;
Expand Down

0 comments on commit 51bb3cc

Please sign in to comment.