-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Question about narrow/wide string conversion #690
Comments
One case is mentioned in http://fmtlib.net/latest/index.html#safety, but otherwise I don't think it's documented, just enforced by compile-time checks. Combining multi-byte (narrow) and wide strings is prohibited for reasons explained in #606.
It shouldn't compile in the master branch: https://godbolt.org/g/JVA8MZ.
This shouldn't compile either: https://godbolt.org/g/WqaYrN
Good catch, thanks! |
Ok I found the issue. For wide to narrow
will call the For narrow to wide
which then handles the narrow string as a custom type, which leads to this
with |
Including
|
Fixed in e8e006f. Now all the cases except formatting a narrow char into a wide string are disallowed. Thanks for reporting! |
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');
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");
Then there seem to be compile error tests in fmt/test/compile-test/CmakeLists.txt which look broken:
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!
The text was updated successfully, but these errors were encountered: