Hi,
dvbcut has problems with filenames containing unicode characters like german
umlauts. Attached is a patch which will fix this. The problem is, that when
you convert from a QString to a std::string or vice versa you have to
encode/decode the string. I hope i have found all locations where to
encode/decode the string.
Michael
--- ./src/dvbcut.cpp 2007-07-29 00:03:50.000000000 +0200
+++ ./src/dvbcut.cpp 2007-09-02 22:15:53.000000000 +0200
@@ -202,7 +202,7 @@
}
QString s=QFileDialog::getSaveFileName(
- prjfilen,
+ QFile::decodeName(prjfilen.c_str()),
settings.prjfilter,
this,
"Save project as...",
@@ -217,7 +217,7 @@
QMessageBox::Yes)
return;
- prjfilen=(const char*)s;
+ prjfilen=(const char*)QFile::encodeName(s);
if (!prjfilen.empty())
fileSave();
}
@@ -229,10 +229,10 @@
return;
}
- QFile outfile(prjfilen);
+ QFile outfile(QFile::decodeName(prjfilen.c_str()));
if (!outfile.open(IO_WriteOnly)) {
critical("Failed to write project file - dvbcut",
- QString(prjfilen) + ":\nCould not open file");
+ outfile.name() + ":\nCould not open file");
return;
}
@@ -248,14 +248,14 @@
std::list<std::string>::const_iterator it = mpgfilen.begin();
while (it != mpgfilen.end()) {
QDomElement elem = doc.createElement("mpgfile");
- elem.setAttribute("path", *it);
+ elem.setAttribute("path", QFile::decodeName((*it).c_str()));
root.appendChild(elem);
++it;
}
if (!idxfilen.empty()) {
QDomElement elem = doc.createElement("idxfile");
- elem.setAttribute("path", idxfilen);
+ elem.setAttribute("path", QFile::decodeName(idxfilen.c_str()));
root.appendChild(elem);
}
@@ -303,7 +303,7 @@
newexpfilen=newexpfilen.substr(0,lastdot);
expfilen=newexpfilen+".mpg";
int nr=0;
- while (QFileInfo(QString(expfilen)).exists())
+ while (QFileInfo(QFile::decodeName(expfilen.c_str())).exists())
expfilen=newexpfilen+"_"+((const char*)QString::number(++nr))+".mpg";
}
}
@@ -331,15 +331,15 @@
settings.export_format = expd->muxercombo->currentItem();
- expfilen=(const char *)(expd->filenameline->text());
+ expfilen=(const char *)QFile::encodeName(expd->filenameline->text());
if (expfilen.empty())
return;
expd->hide();
}
- if (QFileInfo(expfilen).exists() && question(
+ if (QFileInfo(QFile::decodeName(expfilen.c_str())).exists() && question(
"File exists - dvbcut",
- expfilen+"\nalready exists. "
+ QFile::decodeName(expfilen.c_str())+"\nalready exists. "
"Overwrite?") !=
QMessageBox::Yes)
return;
@@ -351,7 +351,7 @@
}
else {
prgwin = new progresswindow(this);
- prgwin->setCaption(QString("export - " + expfilen));
+ prgwin->setCaption(QString("export - ") + QFile::decodeName(expfilen.c_str()));
log = prgwin;
}
@@ -729,7 +729,7 @@
std::list<std::string>::const_iterator it = mpgfilen.begin();
for (int i = 0; it != mpgfilen.end(); ++i, ++it)
if (i >= partindex)
- mplayer_process->addArgument(QString(*it));
+ mplayer_process->addArgument(QFile::decodeName((*it).c_str()));
mplayer_process->setCommunication(QProcess::Stdout|QProcess::Stderr|QProcess::DupStderr);
@@ -1061,7 +1061,7 @@
int id=0;
for(std::vector<std::pair<std::string,std::string> >::iterator it=settings.recentfiles.begin();
it!=settings.recentfiles.end();++it)
- recentfilespopup->insertItem(it->first,id++);
+ recentfilespopup->insertItem(QFile::decodeName(it->first.c_str()),id++);
}
void dvbcut::loadrecentfile(int id)
@@ -1088,7 +1088,7 @@
if (fn.empty())
return;
for (QStringList::Iterator it = fn.begin(); it != fn.end(); ++it)
- filenames.push_back((const char*)*it);
+ filenames.push_back((const char*)QFile::encodeName(*it));
// remember directory
QString dir = fn.front();
@@ -1108,7 +1108,7 @@
std::string filename = filenames.front();
// a valid file name has been entered
- setCaption(QString(VERSION_STRING " - " + filename));
+ setCaption(QString(VERSION_STRING " - ") + QFile::decodeName(filename.c_str()));
// reset inbuffer
buf.reset();
@@ -1174,7 +1174,7 @@
std::string prjfilename;
QDomDocument domdoc;
{
- QFile infile(filename);
+ QFile infile(QFile::decodeName(filename.c_str()));
if (infile.open(IO_ReadOnly)) {
QString line;
while (line.length()==0) {
@@ -1189,7 +1189,7 @@
QDomElement docelem = domdoc.documentElement();
if (docelem.tagName() != "dvbcut") {
critical("Failed to read project file - dvbcut",
- QString(filename) + ":\nNot a valid dvbcut project file");
+ QFile::decodeName(filename.c_str()) + ":\nNot a valid dvbcut project file");
fileOpenAction->setEnabled(true);
return;
}
@@ -1205,29 +1205,29 @@
if (e.tagName() == "mpgfile") {
qs = e.attribute("path");
if (!qs.isEmpty())
- filenames.push_back((const char*)qs);
+ filenames.push_back((const char*)QFile::encodeName(qs));
}
else if (e.tagName() == "idxfile") {
qs = e.attribute("path");
if (!qs.isEmpty())
- idxfilename = (const char*)qs;
+ idxfilename = (const char*)QFile::encodeName(qs);
}
}
// try old-style project file format
if (filenames.empty()) {
qs = docelem.attribute("mpgfile");
if (!qs.isEmpty())
- filenames.push_back((const char*)qs);
+ filenames.push_back((const char*)QFile::encodeName(qs));
}
if (idxfilename.empty()) {
qs = docelem.attribute("idxfile");
if (!qs.isEmpty())
- idxfilename = (const char*)qs;
+ idxfilename = (const char*)QFile::encodeName(qs);
}
// sanity check
if (filenames.empty()) {
critical("Failed to read project file - dvbcut",
- QString(filename) + ":\nNo MPEG filename given in project file");
+ QFile::decodeName(filename.c_str()) + ":\nNo MPEG filename given in project file");
fileOpenAction->setEnabled(true);
return;
}
@@ -1235,7 +1235,7 @@
}
else {
critical("Failed to read project file - dvbcut",
- QString(filename) + ":\n" + errormsg);
+ QFile::decodeName(filename.c_str()) + ":\n" + errormsg);
fileOpenAction->setEnabled(true);
return;
}
@@ -1271,13 +1271,13 @@
if (idxfilename.empty()) {
QString s=QFileDialog::getSaveFileName(
- filename+".idx",
+ QFile::decodeName(filename.c_str())+".idx",
settings.idxfilter,
this,
"Choose index file...",
"Choose the name of the index file" );
if (s)
- idxfilename=(const char*)s;
+ idxfilename=(const char*)QFile::encodeName(s);
else {
delete mpg;
mpg=0;
@@ -1343,7 +1343,7 @@
delete mpg;
mpg=0;
critical("Error creating index - dvbcut",
- QString("Cannot create index for\n")+filename+":\n"+errorstring);
+ QString("Cannot create index for\n")+QFile::decodeName(filename.c_str())+":\n"+errorstring);
fileOpenAction->setEnabled(true);
return;
} else if (!errorstring.empty()) {
@@ -1355,7 +1355,7 @@
delete mpg;
mpg=0;
critical("Invalid MPEG file - dvbcut",
- QString("The chosen file\n")+filename+"\ndoes not contain any video");
+ QString("The chosen file\n")+QFile::decodeName(filename.c_str())+"\ndoes not contain any video");
fileOpenAction->setEnabled(true);
return;
}
--- ./src/exportdialog.cpp 2007-07-23 23:37:46.000000000 +0200
+++ ./src/exportdialog.cpp 2007-08-31 00:45:39.000000000 +0200
@@ -25,7 +25,7 @@
exportdialog::exportdialog(const std::string &filename, QWidget *parent, const char *name)
:exportdialogbase(parent, name, true)
{
- filenameline->setText(filename);
+ filenameline->setText(QFile::decodeName(filename.c_str()));
}
void exportdialog::fileselector()
--- ./src/progresswindow.cpp 2007-07-23 23:37:46.000000000 +0200
+++ ./src/progresswindow.cpp 2007-09-02 22:46:24.000000000 +0200
@@ -156,5 +156,5 @@
QString progresswindow::quotetext(const char *text)
{
- return QString(text).replace('&',QString("&")).replace('<',QString("<")).replace('>',QString(">"));
+ return QString::fromLocal8Bit(text).replace('&',QString("&")).replace('<',QString("<")).replace('>',QString(">"));
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
DVBCUT-user mailing list
DVBCUT-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-user