diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-02-18 12:49:12 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-02-18 12:49:12 +0100 |
| commit | 56924f780f39fb89222b43a438b65d4cac7ff42d (patch) | |
| tree | 4b1e78a0999d68d8888eeb97c3be4823ae8d63fb | |
| parent | 06a01e394f011bd8ae689aa9c206b20010c000b6 (diff) | |
| parent | 2029e433b0d65f7c07f050652df259994304b2ff (diff) | |
| download | mullvadvpn-56924f780f39fb89222b43a438b65d4cac7ff42d.tar.xz mullvadvpn-56924f780f39fb89222b43a438b65d4cac7ff42d.zip | |
Merge branch 'update-install-log-encoding'
| -rw-r--r-- | windows/nsis-plugins/src/log/log.cpp | 2 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/log/logger.cpp | 19 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/log/logger.h | 10 | ||||
| m--------- | windows/windows-libraries | 0 |
4 files changed, 19 insertions, 12 deletions
diff --git a/windows/nsis-plugins/src/log/log.cpp b/windows/nsis-plugins/src/log/log.cpp index 3a5e6579ec..1fc5c2a05f 100644 --- a/windows/nsis-plugins/src/log/log.cpp +++ b/windows/nsis-plugins/src/log/log.cpp @@ -237,7 +237,7 @@ void __declspec(dllexport) NSISCALL Initialize const auto logfile = decltype(logpath)(logpath).append(L"install.log"); - g_logger = new Logger(std::make_unique<AnsiFileLogSink>(logfile)); + g_logger = new Logger(std::make_unique<Utf8FileLogSink>(logfile)); break; diff --git a/windows/nsis-plugins/src/log/logger.cpp b/windows/nsis-plugins/src/log/logger.cpp index 8e3b6e6298..611e323282 100644 --- a/windows/nsis-plugins/src/log/logger.cpp +++ b/windows/nsis-plugins/src/log/logger.cpp @@ -5,7 +5,7 @@ #include <sstream> #include <iomanip> -AnsiFileLogSink::AnsiFileLogSink(const std::wstring &file, bool append, bool flush) +Utf8FileLogSink::Utf8FileLogSink(const std::wstring &file, bool append, bool flush) : m_flush(flush) { const DWORD creationDisposition = (append ? OPEN_ALWAYS : CREATE_ALWAYS); @@ -31,20 +31,27 @@ AnsiFileLogSink::AnsiFileLogSink(const std::wstring &file, bool append, bool flu } } -AnsiFileLogSink::~AnsiFileLogSink() +Utf8FileLogSink::~Utf8FileLogSink() { CloseHandle(m_logfile); } -void AnsiFileLogSink::log(const std::wstring &message) +void Utf8FileLogSink::log(const std::wstring &message) { - auto ansi = common::string::ToAnsi(message); + auto utf8String = common::string::ToUtf8(message); + utf8String.pop_back(); // remove the null char - ansi.append("\xd\xa"); + if (0 == utf8String.size()) + { + return; + } + + utf8String.push_back('\xd'); + utf8String.push_back('\xa'); DWORD bytesWritten; - WriteFile(m_logfile, ansi.c_str(), ansi.size(), &bytesWritten, nullptr); + WriteFile(m_logfile, utf8String.data(), utf8String.size(), &bytesWritten, nullptr); if (m_flush) { diff --git a/windows/nsis-plugins/src/log/logger.h b/windows/nsis-plugins/src/log/logger.h index fe06072581..6847d8a805 100644 --- a/windows/nsis-plugins/src/log/logger.h +++ b/windows/nsis-plugins/src/log/logger.h @@ -21,15 +21,15 @@ public: void log(const std::wstring &message) override {} }; -class AnsiFileLogSink : public ILogSink +class Utf8FileLogSink : public ILogSink { public: - AnsiFileLogSink(const std::wstring &file, bool append = true, bool flush = false); - ~AnsiFileLogSink(); + Utf8FileLogSink(const std::wstring &file, bool append = true, bool flush = false); + ~Utf8FileLogSink(); - AnsiFileLogSink(const AnsiFileLogSink &) = delete; - AnsiFileLogSink &operator=(const AnsiFileLogSink &) = delete; + Utf8FileLogSink(const Utf8FileLogSink &) = delete; + Utf8FileLogSink &operator=(const Utf8FileLogSink &) = delete; void log(const std::wstring &message) override; diff --git a/windows/windows-libraries b/windows/windows-libraries -Subproject 9f49143c1dcdc577c8bb34ad82d7ae16001306d +Subproject ed2da7cb6b7ddf11b6f824258e842b91b453109 |
