This is pretty much a companion of #2447 / #2475. The aforementioned bugs/patches introduce the ability to get the hex dump from a ByteBuffer which is awesome.
Next, I'd like to construct/write into a ByteBuffer from a hex dump:
var allBytes = ByteBuffer()
for x in UInt8.min ... UInt8.max {
buffer.writeInteger(x)
}
let allBytesHex = allBytes.hexDump(format: .plain)
let allBytesDecoded = ByteBuffer(hexEncodedBytes: allBytesHex)
XCTAssertEqual(allBytes, allBytesDecoded)
This is pretty much a companion of #2447 / #2475. The aforementioned bugs/patches introduce the ability to get the hex dump from a
ByteBuffer
which is awesome.Next, I'd like to construct/write into a
ByteBuffer
from a hex dump:ByteBuffer(hexEncodedBytes: "68 65 6c 6c 6f 20 77 6f 72 6c 64 0a")
buffer.writeHexEncodedBytes("68656c6c6f20776f726c640a")
I'd say it just needs to support the
.plain
format (i.e. 2 hex-digit values with whitespace ignored)Super basic test:
another one: