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

Enhancement: format (u)int8 types correctly to number, if formatted with %d, &i, %u #60

Open
s-martin opened this issue Oct 5, 2018 · 2 comments

Comments

@s-martin
Copy link

s-martin commented Oct 5, 2018

If I try to format a (u)int8 number, Boost.Format considers this as (unsigned) char, even if I use %d, %i or %u.

This is a known and rather old issue.

The workaround is to cast the number to (u)int32, before formatting.

Nevertheless the current behavior leads to very subtle bugs, because the developer has to check the type of the number to be printed very carefully.

Plain printf handles (u)int8 numbers in combination with %d, %i or %u correctly.

Boost version: 1.68 (32bit)
Compiler: MSVC 15.8

@k15tfu
Copy link

k15tfu commented Dec 3, 2019

Just faced with the same issue trying to format GUID to its string representation. I use %02X to format the last bytes, but unexpectedly it was shown as non-US-ASCII character =(.

It there any plans to fix this? cc @jeking3

@maddanio
Copy link

I don't think this is an enhancement. This just bit me and imho it's a plain bug: i specifically ask for some kind of numeric formatting and it simply doesnt. If I specify '%x' and the argument is a string it should just throw.

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

3 participants