Skip to content
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

Crash when using fmt with gcc to print chinese character #4162

Closed
WennerChen opened this issue Sep 14, 2024 · 3 comments
Closed

Crash when using fmt with gcc to print chinese character #4162

WennerChen opened this issue Sep 14, 2024 · 3 comments

Comments

@WennerChen
Copy link

WennerChen commented Sep 14, 2024

I want to print chinese character with fmt::print. Here is my code.

#define FMT_HEADER_ONLY
#include <fmt/printf.h>
int main() {
    fmt::print(" 我喜欢fmt \n");
    fmt::print("I like fmt\n");
    while (1) {
        // do nothing
    }
    return 0;
}

My toolchain is mingw-w64 + gcc8.5.0, and my source file is saved as utf-8. When built with options -finput-charset=utf-8 -fexec-charset=gb2312, the generated exe prints nothing but just exits.

FMT-11.0.2 and FMT-10.2.1 are both tested, and the results are same.

@vitaut
Copy link
Contributor

vitaut commented Sep 14, 2024

GCC doesn't have -finput-character and -fexec-character. Did you mean -finput-charset and -fexec-charset?

@WennerChen
Copy link
Author

GCC doesn't have -finput-character and -fexec-character. Did you mean -finput-charset and -fexec-charset?

Yes. Sorry about that.

@vitaut
Copy link
Contributor

vitaut commented Sep 15, 2024

Should be fixed in b329ff1 but note that using legacy encoding is not recommended.

@vitaut vitaut closed this as completed Sep 15, 2024
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

No branches or pull requests

2 participants