diff options
author | Daniel Coonce <danielcoonce@gmail.com> | 2021-01-30 21:35:57 -0600 |
---|---|---|
committer | Martin Michlmayr <tbm@cyrius.com> | 2021-02-02 18:19:31 +0800 |
commit | 13eb0a574f22bb40e8ed0ea4be70be44eb266938 (patch) | |
tree | dabf4c5e63a9c16341b79465dc236e774820c007 | |
parent | d8ed12f600bf9ca958cb9f285ceb10f5d8accbd3 (diff) | |
download | fork-ledger-13eb0a574f22bb40e8ed0ea4be70be44eb266938.tar.gz fork-ledger-13eb0a574f22bb40e8ed0ea4be70be44eb266938.tar.bz2 fork-ledger-13eb0a574f22bb40e8ed0ea4be70be44eb266938.zip |
Use Boost library to read argv as UTF-8 in Windows
Windows uses UTF-16 for command line arguments, so use boost::nowide
to convert to UTF-8.
Fixes #1986
-rw-r--r-- | CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/main.cc | 8 | ||||
-rw-r--r-- | src/system.hh.in | 1 |
3 files changed, 16 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d302761a..9f7e4ca5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,13 @@ endif() # Set BOOST_ROOT to help CMake to find the right Boost version find_package(Boost 1.49.0 REQUIRED date_time filesystem system iostreams regex unit_test_framework - ${BOOST_PYTHON}) + ${BOOST_PYTHON} OPTIONAL_COMPONENTS nowide) + +# enable Boost::nowide library (for UTF8 command line args on Windows) +set(HAVE_BOOST_NOWIDE 0) +if (Boost_NOWIDE_FOUND) + set(HAVE_BOOST_NOWIDE 1) +endif() include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) diff --git a/src/main.cc b/src/main.cc index 218579cf..37203ff4 100644 --- a/src/main.cc +++ b/src/main.cc @@ -35,6 +35,10 @@ // was moved there for the sake of clarity here #include "session.h" +#if HAVE_BOOST_NOWIDE +#include <boost/nowide/args.hpp> +#endif + #ifdef HAVE_EDIT #include <editline/readline.h> #endif @@ -51,6 +55,10 @@ int main(int argc, char * argv[], char * envp[]) { int status = 1; +#if HAVE_BOOST_NOWIDE + boost::nowide::args a(argc, argv); // Fix command-line encoding on Windows +#endif + #if HAVE_BOOST_PYTHON argv0 = argv[0]; #endif diff --git a/src/system.hh.in b/src/system.hh.in index 97b2bead..0cfcf9ed 100644 --- a/src/system.hh.in +++ b/src/system.hh.in @@ -71,6 +71,7 @@ #define HAVE_GPGME @HAVE_GPGME@ #define HAVE_BOOST_REGEX_UNICODE @HAVE_BOOST_REGEX_UNICODE@ #define HAVE_BOOST_159_ISSUE_39 @HAVE_BOOST_159_ISSUE_39@ +#define HAVE_BOOST_NOWIDE @HAVE_BOOST_NOWIDE@ #define DEBUG_MODE @DEBUG_MODE@ #define NO_ASSERTS @NO_ASSERTS@ |