Skip to content

Inconsistent widths when UTF8 characters are used #4851

Description

@YanzhaoW

Hi,

I find the widths are inconsistent when UTF8 characters are used. I'm not sure whether it's caused by the character display of the terminal or the library implementation.

Example:

#include <fmt/format.h>

auto main() -> int {
    fmt::println("|{:^20}|", 12345);
    fmt::println("|{:^20}|", "normal string");
    fmt::println("|{:^20}|", "");
    fmt::println("|{:^20}|", "");
    fmt::println("|{:^20}|", "Müller");
    fmt::println("|{:^20}|", "");
    return 0;
}

Printouts:

|       12345        |
|   normal string    |
|         ❌          |
|         ✅          |
|       Müller       |
|         我         |

Godbolt link

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