comparison transform/CSVFeatureWriter.cpp @ 1035:d74ebd2d2c49

Require (and provide) text codec for output stream -- fixing #1153 (wrong codec used when writing RDF)
author Chris Cannam
date Mon, 02 Mar 2015 17:17:59 +0000
parents d954e03274e8
children b14064bd1f97
comparison
equal deleted inserted replaced
1025:88b54a185a0a 1035:d74ebd2d2c49
21 21
22 #include <iostream> 22 #include <iostream>
23 23
24 #include <QRegExp> 24 #include <QRegExp>
25 #include <QTextStream> 25 #include <QTextStream>
26 #include <QTextCodec>
26 27
27 using namespace std; 28 using namespace std;
28 using namespace Vamp; 29 using namespace Vamp;
29 30
30 CSVFeatureWriter::CSVFeatureWriter() : 31 CSVFeatureWriter::CSVFeatureWriter() :
121 TransformId transformId = transform.getIdentifier(); 122 TransformId transformId = transform.getIdentifier();
122 123
123 // Select appropriate output file for our track/transform 124 // Select appropriate output file for our track/transform
124 // combination 125 // combination
125 126
126 QTextStream *sptr = getOutputStream(trackId, transformId); 127 QTextStream *sptr = getOutputStream(trackId,
128 transformId,
129 QTextCodec::codecForName("UTF-8"));
127 if (!sptr) { 130 if (!sptr) {
128 throw FailedToOpenOutputStream(trackId, transformId); 131 throw FailedToOpenOutputStream(trackId, transformId);
129 } 132 }
130 133
131 QTextStream &stream = *sptr; 134 QTextStream &stream = *sptr;
167 { 170 {
168 for (PendingFeatures::const_iterator i = m_pending.begin(); 171 for (PendingFeatures::const_iterator i = m_pending.begin();
169 i != m_pending.end(); ++i) { 172 i != m_pending.end(); ++i) {
170 DataId tt = i->first; 173 DataId tt = i->first;
171 Plugin::Feature f = i->second; 174 Plugin::Feature f = i->second;
172 QTextStream *sptr = getOutputStream(tt.first, tt.second.getIdentifier()); 175 QTextStream *sptr = getOutputStream(tt.first,
176 tt.second.getIdentifier(),
177 QTextCodec::codecForName("UTF-8"));
173 if (!sptr) { 178 if (!sptr) {
174 throw FailedToOpenOutputStream(tt.first, tt.second.getIdentifier()); 179 throw FailedToOpenOutputStream(tt.first, tt.second.getIdentifier());
175 } 180 }
176 QTextStream &stream = *sptr; 181 QTextStream &stream = *sptr;
177 // final feature has its own time as end time (we can't 182 // final feature has its own time as end time (we can't