swift-nio
swift-nio copied to clipboard
ByteBuffer should have a `.hexdump(format: .compact)`
ByteBuffer has awesome hexdump(format: .detailed | .plain)
formats (from #2475). They're awesome and I use them all the time. But there's one format that I think is quite useful: A compact one without spaces. So
XCTAssertEqual("68656c6c6f20776f726c640a", ByteBuffer(string: "hello world\n").hexdump(format: .compact))
Why is compact so important? Frequently, UNIX tools output formats that are easy to split using cut -d' ' -f2
or awk '{ print $2 }'
or while read -r line prefix hex; do echo "$hex"; done
. But all these require that there's no whitespace in the hexdump.
So I think we should add another format which is exactly like .plain
but doesn't emit spaces or any other whitespace. #2475 made great groundwork here and this should be very easy to add.