diff options
author | Jose <jose@zeroc.com> | 2016-11-08 11:31:04 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2016-11-08 11:31:04 +0100 |
commit | 2bd199b69b49aa93c9eb2efa4cd5276ec638ee38 (patch) | |
tree | 269111a9d02032e7c15dfa6bf9e047541be4aae7 /cpp/src | |
parent | IceUtil msbuild projet fixes (diff) | |
download | ice-2bd199b69b49aa93c9eb2efa4cd5276ec638ee38.tar.bz2 ice-2bd199b69b49aa93c9eb2efa4cd5276ec638ee38.tar.xz ice-2bd199b69b49aa93c9eb2efa4cd5276ec638ee38.zip |
ICE-6692 - Review command line input usage to support unicode on Windows
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceBox/Admin.cpp | 1 | ||||
-rw-r--r-- | cpp/src/IceGrid/Client.cpp | 11 | ||||
-rw-r--r-- | cpp/src/IceGrid/Parser.cpp | 12 | ||||
-rw-r--r-- | cpp/src/IceStorm/Admin.cpp | 14 | ||||
-rw-r--r-- | cpp/src/IceStorm/Parser.cpp | 18 |
5 files changed, 42 insertions, 14 deletions
diff --git a/cpp/src/IceBox/Admin.cpp b/cpp/src/IceBox/Admin.cpp index c7c76bac161..822f144dc5e 100644 --- a/cpp/src/IceBox/Admin.cpp +++ b/cpp/src/IceBox/Admin.cpp @@ -91,7 +91,6 @@ Client::run(int argc, char* argv[]) return EXIT_FAILURE; } - ObjectPrxPtr base = communicator()->propertyToProxy("IceBoxAdmin.ServiceManager.Proxy"); if(base == 0) diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp index c0c58603453..8dafd14f4ed 100644 --- a/cpp/src/IceGrid/Client.cpp +++ b/cpp/src/IceGrid/Client.cpp @@ -31,6 +31,8 @@ # include <termios.h> #else # include <conio.h> +# include <fcntl.h> +# include <io.h> #endif using namespace std; @@ -256,14 +258,17 @@ interruptCallback(int /*signal*/) int wmain(int argc, wchar_t* argv[]) - +{ + // + // Enable binary input mode for stdin to avoid automatic conversions. + // + _setmode(_fileno(stdin), _O_BINARY); #else int main(int argc, char* argv[]) - -#endif { +#endif Client app; StringSeq args = argsToStringSeq(argc, argv); return app.main(args); diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp index 7a88d5247a6..28b09bb87dc 100644 --- a/cpp/src/IceGrid/Parser.cpp +++ b/cpp/src/IceGrid/Parser.cpp @@ -2654,9 +2654,7 @@ Parser::getInput(char* buf, size_t& result, size_t maxSize) } } #else - cout << parser->getPrompt() << flush; - string line; while(true) { @@ -2669,14 +2667,19 @@ Parser::getInput(char* buf, size_t& result, size_t maxSize) } break; } - line += c; + line += c; if(c == '\n') { break; } } - +#ifdef _WIN32 + if(windowsConsoleConverter) + { + line = nativeToUTF8(line, windowsConsoleConverter); + } +#endif result = line.length(); if(result > maxSize) { @@ -2688,7 +2691,6 @@ Parser::getInput(char* buf, size_t& result, size_t maxSize) { strcpy(buf, line.c_str()); } - #endif } } diff --git a/cpp/src/IceStorm/Admin.cpp b/cpp/src/IceStorm/Admin.cpp index 865139f91a0..60c206b116a 100644 --- a/cpp/src/IceStorm/Admin.cpp +++ b/cpp/src/IceStorm/Admin.cpp @@ -12,6 +12,11 @@ #include <Ice/SliceChecksums.h> #include <IceStorm/Parser.h> +#ifdef _WIN32 +# include <fcntl.h> +# include <io.h> +#endif + using namespace std; using namespace Ice; using namespace IceStorm; @@ -28,14 +33,17 @@ public: int wmain(int argc, wchar_t* argv[]) - +{ + // + // Enable binary input mode for stdin to avoid automatic conversions. + // + _setmode(_fileno(stdin), _O_BINARY); #else int main(int argc, char* argv[]) - -#endif { +#endif Client app; Ice::InitializationData id; Ice::StringSeq args = Ice::argsToStringSeq(argc, argv); diff --git a/cpp/src/IceStorm/Parser.cpp b/cpp/src/IceStorm/Parser.cpp index ca0c0c5ae7b..df8decb2e14 100644 --- a/cpp/src/IceStorm/Parser.cpp +++ b/cpp/src/IceStorm/Parser.cpp @@ -30,6 +30,10 @@ namespace IceStorm Parser* parser; +#ifdef _WIN32 +Ice::StringConverterPtr windowsConsoleConverter = 0; +#endif + } namespace @@ -489,13 +493,17 @@ Parser::getInput(char* buf, size_t& result, size_t maxSize) } line += c; - if(c == '\n') { break; } } - +#ifdef _WIN32 + if(windowsConsoleConverter) + { + line = nativeToUTF8(line, windowsConsoleConverter); + } +#endif result = line.length(); if(result > maxSize) { @@ -661,6 +669,12 @@ Parser::Parser(const CommunicatorPtr& communicator, const TopicManagerPrx& admin _defaultManager(admin), _managers(managers) { +#ifdef _WIN32 + if(!windowsConsoleConverter) + { + windowsConsoleConverter = Ice::createWindowsStringConverter(GetConsoleOutputCP()); + } +#endif } void |