Skip to content

Commit

Permalink
Merge pull request #1588 from Joern-R/UTF-8-Text-Output
Browse files Browse the repository at this point in the history
XML Ridefile Formats exports - error on Windows
  • Loading branch information
liversedge committed Oct 9, 2015
2 parents 3273ba8 + 0267eec commit 520f92e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/FitlogRideFile.cpp
Expand Up @@ -233,7 +233,12 @@ FitlogFileReader::writeRideFile(Context *context, const RideFile *ride, QFile &f

QByteArray xml = doc.toByteArray(4);
if (!file.open(QIODevice::WriteOnly)) return(false);
if (file.write(xml) != xml.size()) return(false);
file.resize(0);
QTextStream out(&file);
out.setCodec("UTF-8");
out.setGenerateByteOrderMark(true);
out << xml;
out.flush();
file.close();
return(true);
}
8 changes: 6 additions & 2 deletions src/GcRideFile.cpp
Expand Up @@ -270,8 +270,12 @@ GcFileReader::writeRideFile(Context *,const RideFile *ride, QFile &file) const
QByteArray xml = doc.toByteArray(4);
if (!file.open(QIODevice::WriteOnly))
return false;
if (file.write(xml) != xml.size())
return false;
file.resize(0);
QTextStream out(&file);
out.setCodec("UTF-8");
out.setGenerateByteOrderMark(true);
out << xml;
out.flush();
file.close();
return true;
}
7 changes: 6 additions & 1 deletion src/PwxRideFile.cpp
Expand Up @@ -888,7 +888,12 @@ PwxFileReader::writeRideFile(Context *context, const RideFile *ride, QFile &file

QByteArray xml = doc.toByteArray(4);
if (!file.open(QIODevice::WriteOnly)) return(false);
if (file.write(xml) != xml.size()) return(false);
file.resize(0);
QTextStream out(&file);
out.setCodec("UTF-8");
out.setGenerateByteOrderMark(true);
out << xml;
out.flush();
file.close();
return(true);
}
7 changes: 6 additions & 1 deletion src/TcxRideFile.cpp
Expand Up @@ -415,7 +415,12 @@ TcxFileReader::writeRideFile(Context *context, const RideFile *ride, QFile &file
QByteArray xml = toByteArray(context, ride, true, true, true, true);

if (!file.open(QIODevice::WriteOnly)) return(false);
if (file.write(xml) != xml.size()) return(false);
file.resize(0);
QTextStream out(&file);
out.setCodec("UTF-8");
out.setGenerateByteOrderMark(true);
out << xml;
out.flush();
file.close();
return(true);
}

0 comments on commit 520f92e

Please sign in to comment.