Skip to content

Extra characters printed when formatting invalid UTF-8 with precision #3284

Description

@lriesterer

Formatting using string precision fails when there are non-ascii characters.

Here is a code to reproduce (first line works as expected, second doesn't as there is an extra "diamond-shaped" character printed):

#include <fmt/format.h>
int main()
{
    fmt::print(">>{:.6}<<\n", "1234567");
    fmt::print(">>{:.6}<<\n", "123456\xad");
    return 0;
}

https://godbolt.org/z/zzY4Y4Pec

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions