File indexing completed on 2025-03-23 12:47:15
0001 /* 0002 This file is part of the Kate project. 0003 SPDX-FileCopyrightText: 2010 Christoph Cullmann <cullmann@kde.org> 0004 SPDX-FileCopyrightText: 2010-2018 Dominik Haumann <dhaumann@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #include "katetextbuffer.h" 0010 #include <kateglobal.h> 0011 0012 #include <QCoreApplication> 0013 0014 int main(int argc, char *argv[]) 0015 { 0016 // construct core app 0017 QCoreApplication app(argc, argv); 0018 0019 // test mode 0020 KTextEditor::EditorPrivate::enableUnitTestMode(); 0021 0022 // get arguments 0023 QString encoding = app.arguments().at(1); 0024 QString inFile = app.arguments().at(2); 0025 QString outFile = app.arguments().at(3); 0026 0027 Kate::TextBuffer buffer(nullptr); 0028 0029 // set codec 0030 buffer.setFallbackTextCodec(QTextCodec::codecForName("ISO 8859-15")); 0031 buffer.setTextCodec(QTextCodec::codecForName(encoding.toLatin1())); 0032 0033 // switch to Mac EOL, this will test eol detection, as files are normal unix or dos 0034 buffer.setEndOfLineMode(Kate::TextBuffer::eolMac); 0035 0036 // load file 0037 bool encodingErrors = false; 0038 bool tooLongLines = false; 0039 int longestLineLoaded; 0040 if (!buffer.load(inFile, encodingErrors, tooLongLines, longestLineLoaded, false) || encodingErrors) { 0041 return 1; 0042 } 0043 0044 // save file 0045 if (!buffer.save(outFile)) { 0046 return 1; 0047 } 0048 0049 return 0; 0050 }