Fix stdin/stdout encoding on Windows. (#2425)

QTextStream uses the system default locale, but this breaks in
various situations: (1) It does not work on the native Windows shell
(cmd.exe, Powershell), since the default Windows locale is Windows-1252,
but the shell uses Windows-850. (2) It also breaks on *nix systems where
the locale is Latin1 or C, which is the case for most CI systems or
build servers.

We allow overriding the detected codec by setting the ENCODING_OVERRIDE
environment variable, but otherwise prefer Windows-850 on Windows and
UTF-8 on any other system, even if LANG is set to something else.

This resolves #2413
This commit is contained in:
Janek Bevendorff authored and GitHub committed 2018-10-28 19:55:00 +01:00
1 parent c9cab250c7
commit 7263dcddfe
19 files changed
+180 -61

No files matched your search

+3 -3
View File
@@ -97,7 +97,7 @@ void setNextPassword(const QString& password)
*/
QString getPassword()
{
QTextStream out(STDOUT, QIODevice::WriteOnly);
TextStream out(STDOUT, QIODevice::WriteOnly);
// return preset password if one is set
if (!Test::nextPasswords.isEmpty()) {
@@ -107,7 +107,7 @@ QString getPassword()
return password;
}
QTextStream in(STDIN, QIODevice::ReadOnly);
TextStream in(STDIN, QIODevice::ReadOnly);
setStdinEcho(false);
QString line = in.readLine();
@@ -123,7 +123,7 @@ QString getPassword()
*/
int clipText(const QString& text)
{
QTextStream err(Utils::STDERR);
TextStream err(Utils::STDERR);
QString programName = "";
QStringList arguments;