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

IOStream: Cannot print non-dec base without prefix #497

Open
jeditekunum opened this issue Oct 16, 2017 · 1 comment
Open

IOStream: Cannot print non-dec base without prefix #497

jeditekunum opened this issue Oct 16, 2017 · 1 comment

Comments

@jeditekunum
Copy link
Contributor

I would like to print out an ethernet MAC address. There appears to be no direct way to do this with IOStream as anything with a hex format is prefixed with "0x". There being 6 bytes to a MAC address I get something like 0xde:0xad:0xbe:0xef:0xfe:0xed when I would rather see de:ad:be:ef:fe:ed.

I could make the enhancement and submit a PR but I would like to get agreement on the approach first. I also just noticed that printf is similar but not the same as standard C printf in its format.

One option would be to add an optional argument to bin(), oct(), hex() to indicate exclusion of the prefix (setting a protected variable). Some additional special character to the format string would need to be added to also manipulate this. Or perhaps just the format could be enhanced without affecting bin()/oct()/hex().

Any recommendations?

@jeditekunum
Copy link
Contributor Author

I just discovered INET::print_mac so that solves my specific issue.

The general issue of printing without prefix remains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant