Skip to content

Commit

Permalink
Merge pull request #281 from akallabeth/bytestring_pretty_print
Browse files Browse the repository at this point in the history
Print CBOR_TYPE_BYTESTRING value as hex string
  • Loading branch information
PJK committed Jun 3, 2023
2 parents 1550555 + 15193f1 commit 219c2e7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,12 @@ static void _cbor_nested_describe(cbor_item_t *item, FILE *out, int indent) {
_cbor_nested_describe(cbor_bytestring_chunks_handle(item)[i], out,
indent + 4);
} else {
const unsigned char* data = cbor_bytestring_handle(item);
fprintf(out, "Definite, length %zuB\n", cbor_bytestring_length(item));
fprintf(out, "%*s", indent + 4, " ");
for (size_t i = 0; i < cbor_bytestring_length(item); i++)
fprintf(out, "%02x", (int)(data[i] & 0xff));
fprintf(out, "\n");
}
break;
}
Expand Down

0 comments on commit 219c2e7

Please sign in to comment.