Skip to content

Commit

Permalink
Test: Fix printing of unicode chars on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Feb 9, 2024
1 parent 6656080 commit 7da8ce3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/boostLocale/test/unit_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,15 @@ std::string to_string(const std::vector<T>& v)
}

/// Put the char into the stream making sure it is readable
/// Fallback to the unicode representation of it (e.g. U+00A0)
/// Fallback to the Unicode representation of it (e.g. U+00A0)
template<typename Char>
void stream_char(std::ostream& s, const Char c)
{
if((c >= '!' && c <= '~') || c == ' ')
s << static_cast<char>(c);
else
s << "U+" << std::hex << std::uppercase << std::setw(sizeof(Char)) << static_cast<unsigned>(c);
s << "U+" << std::hex << std::uppercase << std::setw(sizeof(Char)) << std::setfill('0')
<< static_cast<unsigned>(c);
}

template<typename Char>
Expand Down

0 comments on commit 7da8ce3

Please sign in to comment.