Skip to content

Conversation

@sd-collins
Copy link
Contributor

Fixes #14.

There is a slight issue with compatibility with glibc here, since it will happily truncate in the middle of a multi-byte character. We must instead round lengths down to the nearest character boundary, since we cannot produce rust strings that contain invalid UTF-8.

@sd-collins
Copy link
Contributor Author

Ah, I see there is a default precision value of 6.

Fixes tjol#14.

There is a slight issue with compatibility with glibc here, since it
will happily truncate in the middle of a multi-byte character.
We must instead round lengths down to the nearest character boundary,
since we cannot produce rust strings that contain invalid UTF-8.
@tjol tjol merged commit 00bad0f into tjol:main May 17, 2025
1 check passed
force_sign: false,
width: NumericParam::Literal(0),
precision: NumericParam::Literal(6),
precision: NumericParam::FromArgument, // Placeholder - must not be returned!
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't say I like this overloading of FromArgument but considering adding another variant to NumericParam would be a breaking change to the API I think I agree this is the least worst option

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 this pull request may close these issues.

precision not taken into account for string-types

2 participants