Opened 6 years ago

Last modified 3 years ago

#7064 new Feature Requests

hex() with flag for lowercase output

Reported by: Olaf van der Spek <olafvdspek@…> Owned by: Marshall Clow
Milestone: To Be Determined Component: algorithm
Version: Boost 1.51.0 Severity: Problem
Keywords: Cc:

Description

Could you provide a paramter for hex() to indicate lowercase output is desired?

Change History (7)

comment:1 Changed 6 years ago by Marshall Clow

Is there a use case here? Some existing piece of software that does unhex that only accepts lower case hex digits?

comment:2 Changed 6 years ago by Olaf van der Spek <olafvdspek@…>

Yes. Existing software currently using lowercase output and not wanting to change the output just to take advantage of these Boost functions.

comment:3 Changed 3 years ago by nigels.com@…

Agreed, I prefer to match the output of commandline sha256sum, than have to do the upper to lower case fix.

comment:4 Changed 3 years ago by Marshall Clow

Olaf - I asked if there was "some piece of software that does unhex that only accepts lower case hex digits", and you said "Yes", but gave no examples.

Nigels - You prefer to match the output of sha256sum, but this isn't a checksuming routine. This encodes the bytes into a hex stream.

comment:5 Changed 3 years ago by nigels.com@…

Hi Marhsall - my specific task was to convert binary hash to a hex string matching the output of sha256sum. It made me sad to have to write that manually, rather than use boost::algorithm::hex() A hex_lower() alternative, perhaps? I'd point out that hex_char_to_int already supports lower case.

comment:6 Changed 3 years ago by Olaf van der Spek <olafvdspek@…>

Ah, I misread your question. I don't know if only lowercase is accepted, but I'd like to have full control over the output without having to pipe it through to_lower.

comment:7 Changed 3 years ago by nigels.com@…

I proposed a patch on github: https://github.com/boostorg/algorithm/pull/14

Note: See TracTickets for help on using tickets.