aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-10-05 23:12:42 +0200
committerRiccardo Spagni <ric@spagni.net>2018-10-05 23:12:42 +0200
commit445d9c86f25949a45d159e0a54f758763145a860 (patch)
tree120d691a64d2014a60a481ee46bc73f08223da9d /src/simplewallet
parentMerge pull request #4492 (diff)
parentsecure_pwd_reader: Add proper Unicode handling [Ryo contribution] (diff)
downloadmonero-445d9c86f25949a45d159e0a54f758763145a860.tar.xz
Merge pull request #4390
a0613532 secure_pwd_reader: Add proper Unicode handling [Ryo contribution] (fireice-uk) 579383c2 simplewallet: Add Unicode input_line [Ryo backport] (fireice-uk)
Diffstat (limited to 'src/simplewallet')
-rw-r--r--src/simplewallet/simplewallet.cpp50
1 files changed, 3 insertions, 47 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 90f8535d7..a1d6eb590 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -137,47 +137,6 @@ namespace
const command_line::arg_descriptor< std::vector<std::string> > arg_command = {"command", ""};
-#ifdef WIN32
- // Translate from CP850 to UTF-8;
- // std::getline for a Windows console returns a string in CP437 or CP850; as simplewallet,
- // like all of Monero, is assumed to work internally with UTF-8 throughout, even on Windows
- // (although only implemented partially), a translation to UTF-8 is needed for input.
- //
- // Note that if a program is started inside the MSYS2 shell somebody already translates
- // console input to UTF-8, but it's not clear how one could detect that in order to avoid
- // double-translation; this code here thus breaks UTF-8 input within a MSYS2 shell,
- // unfortunately.
- //
- // Note also that input for passwords is NOT translated, to remain compatible with any
- // passwords containing special characters that predate this switch to UTF-8 support.
- template<typename T>
- static T cp850_to_utf8(const T &cp850_str)
- {
- boost::locale::generator gen;
- gen.locale_cache_enabled(true);
- std::locale loc = gen("en_US.CP850");
- const boost::locale::conv::method_type how = boost::locale::conv::default_method;
- T result;
- const char *begin = cp850_str.data();
- const char *end = begin + cp850_str.size();
- result.reserve(end-begin);
- typedef std::back_insert_iterator<T> inserter_type;
- inserter_type inserter(result);
- boost::locale::utf::code_point c;
- while(begin!=end) {
- c=boost::locale::utf::utf_traits<char>::template decode<char const *>(begin,end);
- if(c==boost::locale::utf::illegal || c==boost::locale::utf::incomplete) {
- if(how==boost::locale::conv::stop)
- throw boost::locale::conv::conversion_error();
- }
- else {
- boost::locale::utf::utf_traits<char>::template encode<inserter_type>(c,inserter);
- }
- }
- return result;
- }
-#endif
-
std::string input_line(const std::string& prompt)
{
#ifdef HAVE_READLINE
@@ -186,9 +145,10 @@ namespace
std::cout << prompt;
std::string buf;
+#ifdef _WIN32
+ buf = tools::input_line_win();
+#else
std::getline(std::cin, buf);
-#ifdef WIN32
- buf = cp850_to_utf8(buf);
#endif
return epee::string_tools::trim(buf);
@@ -208,10 +168,6 @@ namespace
epee::wipeable_string buf = pwd_container->password();
-#ifdef WIN32
- buf = cp850_to_utf8(buf);
-#endif
-
buf.trim();
return buf;
}