From dfb93c58dd3a72178b72ee7bb0b0205883e8996c Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Tue, 29 Aug 2023 21:58:51 +0800 Subject: [PATCH] Use utf-8 on Windows --- chsrc.c | 4 +++- helper.h | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/chsrc.c b/chsrc.c index 4447a01..46c1028 100644 --- a/chsrc.c +++ b/chsrc.c @@ -107,7 +107,7 @@ static const char const pl_ruby, pl_python, pl_nodejs, pl_perl, pl_php, pl_cran, pl_rust, pl_go, pl_dotnet, pl_maven, pl_gradle, pl_julia }; -#undef arg +#undef cmdfunc static const char const* usage[] = { @@ -145,6 +145,8 @@ print_help () int main (int argc, char const *argv[]) { + xy_useutf8(); + // 未提供参数时 if (argc<=1) { print_help(); return 0; diff --git a/helper.h b/helper.h index 0c09a8f..19eca92 100644 --- a/helper.h +++ b/helper.h @@ -12,6 +12,13 @@ #include #include +#ifdef _WIN32 + #include + #define xy_useutf8() SetConsoleOutputCP(65001) +#else + #define xy_useutf8() +#endif + #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) char*