Encode a string as uppercase hex so it contains no whitespace or dots, making it safe to embed in the one-line external-command replay marker.
| 549 | /// Encode a string as uppercase hex so it contains no whitespace or dots, |
| 550 | /// making it safe to embed in the one-line external-command replay marker. |
| 551 | static String markerHexEncode(const String & s) |
| 552 | { |
| 553 | static const char hex_digits[] = "0123456789ABCDEF"; |
| 554 | String result; |
| 555 | result.reserve(s.size() * 2); |
| 556 | for (const unsigned char c : s) |
| 557 | { |
| 558 | result += hex_digits[c >> 4]; |
| 559 | result += hex_digits[c & 0xF]; |
| 560 | } |
| 561 | return result; |
| 562 | } |
| 563 | |
| 564 | /// Decode a hex string written by markerHexEncode. |
| 565 | static String markerHexDecode(const String & s) |