diff --git a/.vscode/settings.json b/.vscode/settings.json index 1879994..ac0711c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -21,9 +21,9 @@ "test.txt" ] }, - // "cmake.configureSettings": { - // "CMAKE_TOOLCHAIN_FILE": "${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" - // }, + "cmake.configureSettings": { + "CMAKE_TOOLCHAIN_FILE": "${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + }, "cmake.options.statusBarVisibility": "visible", "cmake.generator": "Ninja", "C_Cpp.default.compileCommands": "${workspaceRoot}/build/compile_commands.json", @@ -106,6 +106,7 @@ "ranges": "cpp", "span": "cpp", "valarray": "cpp", - "variant": "cpp" + "variant": "cpp", + "xstring": "cpp" } } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 21cdebf..e410c62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) if (MSVC) - add_compile_options(/source-charset:utf-8) + add_compile_options(/utf-8) endif() if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Windows") @@ -24,5 +24,15 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE} include_directories(3rd) find_package(CURL REQUIRED) find_package(OpenSSL REQUIRED) + +if (MSVC) + find_package(Xlnt CONFIG REQUIRED) +endif() + add_executable(fanyi main.cpp handle.h handle.cpp) -target_link_libraries(fanyi CURL::libcurl OpenSSL::SSL OpenSSL::Crypto xlnt) \ No newline at end of file +target_link_libraries(fanyi PRIVATE CURL::libcurl OpenSSL::SSL OpenSSL::Crypto) +if (MSVC) + target_link_libraries(fanyi PRIVATE xlnt::xlnt) +else() + target_link_libraries(fanyi PRIVATE xlnt) +endif() \ No newline at end of file diff --git a/README.md b/README.md index 07a2d65..dd0b164 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,6 @@ windows下需要特殊处理编码问题(API要求为UTF-8)。 - 依赖`libcurl`访问`https`。 - 依赖[xlnt](https://github.com/tfussell/xlnt)生成`xlsx`。 -对于`Debian`系列系统,示例安装`sudo apt install libssl-dev libcurl4-openssl-dev`。 \ No newline at end of file +对于`Debian`系列系统,示例安装`sudo apt install libssl-dev libcurl4-openssl-dev`。 + +对用`windows`系统,可以使用`vcpkg install xlnt openssl curl[ssl]`。 \ No newline at end of file diff --git a/main.cpp b/main.cpp index c2c0a08..70d8626 100644 --- a/main.cpp +++ b/main.cpp @@ -33,6 +33,11 @@ bool parse_result(const std::string& str, std::string& out) int main(int argc, char* argv[]) { + +#if _WIN32 + system("chcp 65001"); +#endif + if (argc < 2) { std::cout << "Second parm is file name(find in current director)." << std::endl; return 0;