Closed linqinghan closed 2 years ago
There is no such feature out of the box. However I'm thinking about adding it. For now you can use hex::dumper
manipulator from http://nlitsme.github.io/posts/hexdumper-for-c%2B%2B-iostreams
ok, thanks!
+1
Sadly that link is now expired.
@Ryder17z You can use this one: https://github.com/nlitsme/cpputils
Now plog supports hex dumps: https://github.com/SergiusTheBest/plog/blob/cab41842b0fdc496241e4a6e413ddc02a1574334/samples/HexDump/Main.cpp#L19-L41 The sample output is:
2022-04-22 21:07:31.616 INFO [208947] [main@28] v: 0a 00 00 00 14 00 00 00 1e 00 00 00 28 00 00 00 40 42 0f 00 80 84 1e 00 c0 c6 2d 00
2022-04-22 21:07:31.616 INFO [208947] [main@29] v: 0a 00 00 00 14 00 00 00 1e 00 00 00 28 00 00 00 40 42 0f 00 80 84 1e 00 c0 c6 2d 00
2022-04-22 21:07:31.616 INFO [208947] [main@30] v: 0a000000140000001e0000002800000040420f0080841e00c0c62d00
2022-04-22 21:07:31.616 INFO [208947] [main@31] v: 0a 00 00 00|14 00 00 00|1e 00 00 00|28 00 00 00|40 42 0f 00|80 84 1e 00|c0 c6 2d 00
2022-04-22 21:07:31.616 INFO [208947] [main@32] v: 0a00000014000000 1e00000028000000 40420f0080841e00 c0c62d00
2022-04-22 21:07:31.616 INFO [208947] [main@35] s: 48 65 6c 6c 6f 21
2022-04-22 21:07:31.616 INFO [208947] [main@38] p: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 34 20 30 30 20 30 30 20 30 30 20 20 31 65 20 30 30 20 30 30 20 30 30 20 32 38 20 30 30 20 30 30 20 30 30 20 20 34 30 20 34 32 20 30 66 20 30 30 20 38 30 20 38 34 20 31 65 20 30 30 20 20 63 30 20 63 36 20 32 64 20 30 30 00 54 90 00 00 00 00 6b a8 5b 90
2022-04-22 21:07:31.616 INFO [208947] [main@41] arr: ff 00 00 00 ff 01 00 00 ff ff 00 00
Excute me, I Have a program,how can't I print the array in hex format?
int my_array[] = {10, 15 20};
print like this:
0xA, 0xF, 0x14
thanks!