Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ByteBuffer should have a .hexdump(format: .compact) #2825

Open
weissi opened this issue Aug 5, 2024 · 2 comments
Open

ByteBuffer should have a .hexdump(format: .compact) #2825

weissi opened this issue Aug 5, 2024 · 2 comments
Labels
good first issue Good for newcomers kind/enhancement Improvements to existing feature. semver/minor Adds new public API.

Comments

@weissi
Copy link
Member

weissi commented Aug 5, 2024

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.

@weissi weissi added kind/enhancement Improvements to existing feature. good first issue Good for newcomers semver/minor Adds new public API. labels Aug 5, 2024
@weissi
Copy link
Member Author

weissi commented Aug 5, 2024

Related to #2748

supersonicbyte added a commit to supersonicbyte/swift-nio that referenced this issue Sep 1, 2024
Motivation:

Resolving the following issue: apple#2825.

Modifications:

• Added a compact format for ByteBuffer's hexdump method

Result:

A new format which is analog to the `.plain` but without whitespaces.
@supersonicbyte
Copy link
Contributor

Made a PR for this!

supersonicbyte added a commit to supersonicbyte/swift-nio that referenced this issue Sep 2, 2024
Motivation:

Resolving the following issue: apple#2825.

Modifications:

• Added a compact format for ByteBuffer's hexdump method

Result:

A new format which is analog to the `.plain` but without whitespaces.
FranzBusch pushed a commit that referenced this issue Sep 3, 2024
Add compact formatting option to ByteBuffer's hexdump method.

### Motivation:

Resolving the following issue:
#2825.

### Modifications:

• Added a compact format for ByteBuffer's hexdump method

### Result:

A new format which is analog to the `.plain` but without whitespaces.

---------

Co-authored-by: Johannes Weiss <[email protected]>
Co-authored-by: Si Beaumont <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers kind/enhancement Improvements to existing feature. semver/minor Adds new public API.
Projects
None yet
Development

No branches or pull requests

2 participants