Fix hex encoding of non-ASCII characters in serial
This commit is contained in:
parent
9df559598a
commit
165bfa3dd6
|
@ -114,7 +114,8 @@ static std::string
|
||||||
hexEncode (std::string const& str) {
|
hexEncode (std::string const& str) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
for (size_t i = 0; i < str.size(); ++i) {
|
for (size_t i = 0; i < str.size(); ++i) {
|
||||||
int c = str[i];
|
unsigned c = str[i];
|
||||||
|
c %= 256;
|
||||||
oss << std::setfill('0') << std::hex << std::setw(2)
|
oss << std::setfill('0') << std::hex << std::setw(2)
|
||||||
<< std::uppercase;
|
<< std::uppercase;
|
||||||
oss << c;
|
oss << c;
|
||||||
|
|
Loading…
Reference in New Issue