diff --git a/arangod/RestServer/ServerFeature.cpp b/arangod/RestServer/ServerFeature.cpp index 8f7ed00657..1eb1a1e708 100644 --- a/arangod/RestServer/ServerFeature.cpp +++ b/arangod/RestServer/ServerFeature.cpp @@ -53,7 +53,8 @@ ServerFeature::ServerFeature( _vstMaxSize(1024 * 30), _result(res), _operationMode(OperationMode::MODE_SERVER), - _codePage(65001) { // default to UTF8 + _codePage(65001), // default to UTF8 + _originalCodePage(UINT16_MAX) { setOptional(true); startsAfter("AQLPhase"); @@ -158,7 +159,10 @@ void ServerFeature::validateOptions(std::shared_ptr options) { void ServerFeature::start() { #if _WIN32 - SetConsoleOutputCP(_codePage); + _originalCodePage = GetConsoleOutputCP(); + if (IsValidCodePage(_codePage)) { + SetConsoleOutputCP(_codePage); + } #endif waitForHeartbeat(); @@ -189,6 +193,14 @@ void ServerFeature::start() { } +void ServerFeature::stop() { +#if _WIN32 + if (IsValidCodePage(_originalCodePage)) { + SetConsoleOutputCP(_originalCodePage); + } +#endif +} + void ServerFeature::beginShutdown() { std::string msg = ArangoGlobalContext::CONTEXT->binaryName() + " [shutting down]"; diff --git a/arangod/RestServer/ServerFeature.h b/arangod/RestServer/ServerFeature.h index 3f7a9e9273..4137534570 100644 --- a/arangod/RestServer/ServerFeature.h +++ b/arangod/RestServer/ServerFeature.h @@ -44,6 +44,7 @@ class ServerFeature final : public application_features::ApplicationFeature { void collectOptions(std::shared_ptr) override final; void validateOptions(std::shared_ptr) override final; void start() override final; + void stop() override final; void beginShutdown() override final; bool isStopping() const { return _isStopping; } @@ -71,6 +72,7 @@ class ServerFeature final : public application_features::ApplicationFeature { OperationMode _operationMode; bool _isStopping = false; uint16_t _codePage; + uint16_t _originalCodePage; }; } diff --git a/arangosh/Shell/ClientFeature.cpp b/arangosh/Shell/ClientFeature.cpp index 497eda6f96..969d506714 100644 --- a/arangosh/Shell/ClientFeature.cpp +++ b/arangosh/Shell/ClientFeature.cpp @@ -66,7 +66,7 @@ ClientFeature::ClientFeature( _warnConnect(true), _haveServerPassword(false), _codePage(65001), // default to UTF8 - _originalCodePage(-1) { + _originalCodePage(UINT16_MAX) { setOptional(true); requiresElevatedPrivileges(false); startsAfter("GreetingsPhase"); @@ -311,14 +311,17 @@ std::vector ClientFeature::httpEndpoints() { void ClientFeature::start() { #if _WIN32 _originalCodePage = GetConsoleOutputCP(); - - SetConsoleOutputCP(_codePage); + if (IsValidCodePage(_codePage)) { + SetConsoleOutputCP(_codePage); + } #endif } void ClientFeature::stop() { #if _WIN32 - SetConsoleOutputCP(_originalCodePage); + if (IsValidCodePage(_originalCodePage)) { + SetConsoleOutputCP(_originalCodePage); + } #endif } diff --git a/lib/ApplicationFeatures/LanguageFeature.cpp b/lib/ApplicationFeatures/LanguageFeature.cpp index d78ce1b83f..c1dc5c0fa5 100644 --- a/lib/ApplicationFeatures/LanguageFeature.cpp +++ b/lib/ApplicationFeatures/LanguageFeature.cpp @@ -71,7 +71,9 @@ void* LanguageFeature::prepareIcu(std::string const& binaryPath, std::string& path, std::string const& binaryName) { std::string fn("icudtl.dat"); - TRI_GETENV("ICU_DATA", path); + if (TRI_GETENV("ICU_DATA", path)) { + path = FileUtils::buildFilename(path, fn); + } if (path.empty() || !TRI_IsRegularFile(path.c_str())) { if (!path.empty()) { LOG_TOPIC(WARN, arangodb::Logger::FIXME)