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

Support char as number #55

Closed
tarwich opened this issue Jul 19, 2014 · 1 comment
Closed

Support char as number #55

tarwich opened this issue Jul 19, 2014 · 1 comment

Comments

@tarwich
Copy link

tarwich commented Jul 19, 2014

This should return 0x61, but instead fails saying it needs a numeric type instead of a character type.

fmt::format("0x{0:02X}", 'a'); // Crashes

This, however, succeeds:

fmt::format("0x{0:02X}\n", (int)'a'); // Returns 0x61
@vitaut
Copy link
Contributor

vitaut commented Jul 21, 2014

Since char is technically an integral type, I think you are right and this should be supported. Thanks for reporting!

tarwich added a commit to tarwich/cppformat that referenced this issue Jul 22, 2014
This hack isn't great, but it fixes the problem. I don't like
being a problem-only kinda guy, so I'm submitting a patch.

Personally I think that cppformat shouldn't be so pedantic. It
seems like if there is a natural conversion from the source to the
destination format, then it should be performed.

Resolves fmtlib#55
@vitaut vitaut closed this as completed in a7d94f0 Jul 22, 2014
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

Successfully merging a pull request may close this issue.

2 participants