summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/linguist/shared/translator.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp
index 8a071d3..2d92dd5 100644
--- a/tools/linguist/shared/translator.cpp
+++ b/tools/linguist/shared/translator.cpp
@@ -44,6 +44,10 @@
#include "simtexth.h"
#include <stdio.h>
+#ifdef Q_OS_WIN
+#include <io.h> // required for _setmode, to avoid _O_TEXT streams...
+#include <fcntl.h> // for _O_BINARY
+#endif
#include <QtCore/QDebug>
#include <QtCore/QDir>
@@ -207,6 +211,10 @@ bool Translator::load(const QString &filename, ConversionData &cd, const QString
QFile file;
if (filename.isEmpty() || filename == QLatin1String("-")) {
+#ifdef Q_OS_WIN
+ // QFile is broken for text files
+ ::_setmode(0, _O_BINARY);
+#endif
if (!file.open(stdin, QIODevice::ReadOnly)) {
cd.appendError(QString::fromLatin1("Cannot open stdin!? (%1)")
.arg(file.errorString()));
@@ -243,6 +251,10 @@ bool Translator::save(const QString &filename, ConversionData &cd, const QString
{
QFile file;
if (filename.isEmpty() || filename == QLatin1String("-")) {
+#ifdef Q_OS_WIN
+ // QFile is broken for text files
+ ::_setmode(1, _O_BINARY);
+#endif
if (!file.open(stdout, QIODevice::WriteOnly)) {
cd.appendError(QString::fromLatin1("Cannot open stdout!? (%1)")
.arg(file.errorString()));