Skip to content

Commit

Permalink
Fix handling of non-printable character bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
top-sekret committed Sep 23, 2024
1 parent 284aaff commit 6f7e604
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions translations.hh
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ append_char (OutputIt out, char ch)
*out++ = ch;
else
{
auto u_ch = static_cast<unsigned char>(ch);

constexpr std::array hex_table{'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

*out++ = '<';
*out++ = '0';
*out++ = 'x';
*out++ = hex_table[ch >> 4];
*out++ = hex_table[ch & 0x0F];
*out++ = hex_table[u_ch / 16];
*out++ = hex_table[u_ch % 16];
*out++ = '>';
}

Expand Down

0 comments on commit 6f7e604

Please sign in to comment.