+ unify DLL export defines to namespace names
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5000 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
50
src/Tools/encode/lencode.cpp
Normal file
50
src/Tools/encode/lencode.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
#include <qtextcodec.h>
|
||||
#include <qfile.h>
|
||||
#include <qtextstream.h>
|
||||
#include <qdom.h>
|
||||
|
||||
void encodeFile(QTextCodec *codec, const char *fileName);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 3) {
|
||||
qWarning("Usage: lencode encoding file1.ts...");
|
||||
return 1;
|
||||
}
|
||||
|
||||
QTextCodec *codec = QTextCodec::codecForName(argv[1]);
|
||||
if (!codec) {
|
||||
qWarning("Unknown encoding: %s", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int i = 2; i < argc; ++i)
|
||||
encodeFile(codec, argv[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void encodeFile(QTextCodec *codec, const char *fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
QDomDocument doc;
|
||||
|
||||
if (!file.open(IO_ReadOnly | IO_Translate))
|
||||
; // handle error
|
||||
if (!doc.setContent(&file, true))
|
||||
; // handle error
|
||||
|
||||
if (doc.firstChild().isProcessingInstruction() && doc.firstChild().nodeName() == "xml")
|
||||
doc.removeChild(doc.firstChild());
|
||||
|
||||
QDomNode node = doc.createProcessingInstruction("xml",QString("version=\"1.0\" encoding=\"") + codec->mimeName() + "\"");
|
||||
doc.insertBefore(node, doc.firstChild());
|
||||
|
||||
file.close();
|
||||
if (!file.open(IO_WriteOnly | IO_Translate))
|
||||
; // handle error
|
||||
QTextStream out(&file);
|
||||
doc.save(out, 4);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user