Skip to content

Commit 6f7e604

Browse files
committed
Fix handling of non-printable character bytes
1 parent 284aaff commit 6f7e604

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

translations.hh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,16 @@ append_char (OutputIt out, char ch)
6464
*out++ = ch;
6565
else
6666
{
67+
auto u_ch = static_cast<unsigned char>(ch);
68+
6769
constexpr std::array hex_table{'0', '1', '2', '3', '4', '5', '6', '7',
6870
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
6971

7072
*out++ = '<';
7173
*out++ = '0';
7274
*out++ = 'x';
73-
*out++ = hex_table[ch >> 4];
74-
*out++ = hex_table[ch & 0x0F];
75+
*out++ = hex_table[u_ch / 16];
76+
*out++ = hex_table[u_ch % 16];
7577
*out++ = '>';
7678
}
7779

0 commit comments

Comments
 (0)