Skip to content

Question about narrow/wide string conversion #690

Closed
@sebkoenig

Description

@sebkoenig

Is there a documentation about which char type conversions are supposed to work and which should not work by design?

Narrow string to wide string output seems to work:
fmt::format(L"{}", "foo");

Wide char to narrow string seems to be explictly unsupported with a static_assert
fmt::format("{}", L'f');

formatting of wide characters into a narrow output is disallowed

Wide string to narrow string compiles, but puts the memory address of the wide string into the output, which doesn't look like intended behavior?
fmt::format("{}", L"foo");

"0x7ff6f817dc80"

Then there seem to be compile error tests in fmt/test/compile-test/CmakeLists.txt which look broken:

# Formatting a wide string with a narrow format string is forbidden.
expect_compile_error("fmt::format(\"{}\", L\"foo\";")

Looks like a missing ) for the function call?

Can someone please explain why (or correct me if I am wrong) narrow to wide is supported, but wide to narrow should not work?
Thanks!

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