| 63 | } |
| 64 | |
| 65 | std::string Blob::toString(const uint8_t* value, uint64_t len) { |
| 66 | std::string result; |
| 67 | for (auto i = 0u; i < len; i++) { |
| 68 | if (isRegularChar(value[i])) { |
| 69 | // ascii characters are rendered as-is. |
| 70 | result += value[i]; |
| 71 | } else { |
| 72 | auto firstByte = value[i] >> HexFormatConstants::NUM_BYTES_TO_SHIFT_FOR_FIRST_BYTE; |
| 73 | auto secondByte = value[i] & HexFormatConstants::SECOND_BYTE_MASK; |
| 74 | // non-ascii characters are rendered as hexadecimal (e.g. \x00). |
| 75 | result += '\\'; |
| 76 | result += 'x'; |
| 77 | result += HexFormatConstants::HEX_TABLE[firstByte]; |
| 78 | result += HexFormatConstants::HEX_TABLE[secondByte]; |
| 79 | } |
| 80 | } |
| 81 | return result; |
| 82 | } |
| 83 | |
| 84 | void Blob::validateHexCode(const uint8_t* blobStr, uint64_t length, uint64_t curPos) { |
| 85 | if (curPos + HexFormatConstants::LENGTH > length) { |
no test coverage detected