Cosa
Cosa copied to clipboard
IOStream: Cannot print non-dec base without prefix
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?
I just discovered INET::print_mac so that solves my specific issue.
The general issue of printing without prefix remains.