From 91dc7e645714951bb499cb3df691795967fc08a0 Mon Sep 17 00:00:00 2001 From: sowle Date: Fri, 27 Sep 2019 05:36:31 +0300 Subject: [PATCH 1/3] filesystem unicode support: simplewallet improvements (command line made unicode-able) #121 --- src/simplewallet/simplewallet.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index db6e604f..68f65a96 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -331,7 +331,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) } else { - bool r = open_wallet(epee::string_encoding::convert_to_ansii(m_wallet_file), pwd_container.password()); + bool r = open_wallet(m_wallet_file, pwd_container.password()); CHECK_AND_ASSERT_MES(r, false, "could not open account"); } @@ -379,7 +379,7 @@ bool simple_wallet::new_wallet(const string &wallet_file, const std::string& pas m_wallet->set_do_rise_transfer(false); try { - m_wallet->generate(epee::string_encoding::convert_to_unicode(m_wallet_file), password); + m_wallet->generate(epee::string_encoding::utf8_to_wstring(m_wallet_file), password); message_writer(epee::log_space::console_color_white, true) << "Generated new wallet: " << m_wallet->get_account().get_public_address_str(); std::cout << "view key: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key) << std::endl << std::flush; if(m_do_not_set_date) @@ -421,7 +421,7 @@ bool simple_wallet::restore_wallet(const std::string &wallet_file, const std::st m_wallet->set_do_rise_transfer(false); try { - m_wallet->restore(epee::string_encoding::convert_to_unicode(wallet_file), password, restore_seed); + m_wallet->restore(epee::string_encoding::utf8_to_wstring(wallet_file), password, restore_seed); message_writer(epee::log_space::console_color_white, true) << "Wallet restored: " << m_wallet->get_account().get_public_address_str(); std::cout << "view key: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key) << std::endl << std::flush; if (m_do_not_set_date) @@ -457,7 +457,7 @@ bool simple_wallet::open_wallet(const string &wallet_file, const std::string& pa { try { - m_wallet->load(epee::string_encoding::convert_to_unicode(m_wallet_file), password); + m_wallet->load(epee::string_encoding::utf8_to_wstring(m_wallet_file), password); message_writer(epee::log_space::console_color_white, true) << "Opened" << (m_wallet->is_watch_only() ? " watch-only" : "") << " wallet: " << m_wallet->get_account().get_public_address_str(); if (m_print_brain_wallet) @@ -1512,7 +1512,11 @@ bool simple_wallet::submit_transfer(const std::vector &args) return true; } //---------------------------------------------------------------------------------------------------- +#ifdef WIN32 +int wmain( int argc, wchar_t* argv_w[ ], wchar_t* envp[ ] ) +#else int main(int argc, char* argv[]) +#endif { #ifdef WIN32 _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); @@ -1528,6 +1532,18 @@ int main(int argc, char* argv[]) std::fflush(nullptr); }); +#ifdef WIN32 + // windows: convert argv_w into UTF-8-encoded std::string the same way it is in Linux and macOS + std::vector argv_str; + std::vector argv_vec; + for (size_t i = 0; i < argc; ++i) + { + argv_str.push_back( epee::string_encoding::wstring_to_utf8( argv_w[i] ) ); + argv_vec.push_back( argv_str.back().c_str() ); + } + const char* const* argv = argv_vec.data(); +#endif + string_tools::set_module_name_and_folder(argv[0]); po::options_description desc_general("General options"); @@ -1662,7 +1678,7 @@ int main(int argc, char* argv[]) try { LOG_PRINT_L0("Loading wallet..."); - wal.load(epee::string_encoding::convert_to_unicode(wallet_file), pwd_container.password()); + wal.load(epee::string_encoding::utf8_to_wstring(wallet_file), pwd_container.password()); } catch (const tools::error::wallet_load_notice_wallet_restored& e) { From 3d574ca7a8cdb858a421847e700146ff756f2840 Mon Sep 17 00:00:00 2001 From: sowle Date: Fri, 27 Sep 2019 05:37:09 +0300 Subject: [PATCH 2/3] common: parse_command_line minor improvement --- src/common/command_line.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/command_line.h b/src/common/command_line.h index 1f14ef22..8b96524a 100644 --- a/src/common/command_line.h +++ b/src/common/command_line.h @@ -122,7 +122,7 @@ namespace command_line boost::program_options::basic_parsed_options parse_command_line(int argc, const charT* const argv[], const boost::program_options::options_description& desc, bool allow_unregistered = false) { - auto parser = boost::program_options::command_line_parser(argc, argv); + auto parser = boost::program_options::basic_command_line_parser(argc, argv); parser.options(desc); if (allow_unregistered) { From b1af1d7daa14210b721b5539b433e681fad8fce2 Mon Sep 17 00:00:00 2001 From: sowle Date: Fri, 27 Sep 2019 05:37:56 +0300 Subject: [PATCH 3/3] === build number: 59 -> 60 === --- src/version.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h.in b/src/version.h.in index 79ce4b03..b084d7d3 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -7,6 +7,6 @@ #define PROJECT_REVISION "0" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 59 +#define PROJECT_VERSION_BUILD_NO 60 #define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO) #define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]"