MCPcopy Create free account
hub / github.com/QNapi/qnapi / ppChangeSubtitlesEncoding

Method ppChangeSubtitlesEncoding

libqnapi/src/subtitlepostprocessor.cpp:84–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84bool SubtitlePostProcessor::ppChangeSubtitlesEncoding(
85 const QString& subtitleFilePath, const QString& from,
86 const QString& to) const {
87 QFile f(subtitleFilePath);
88 if (!f.open(QIODevice::ReadOnly)) return false;
89
90 QByteArray fileContent = f.readAll();
91
92 QString contentStr =
93 QTextCodec::codecForName(qPrintable(from))->toUnicode(fileContent);
94 f.close();
95
96 if (to.compare("UTF-8", Qt::CaseInsensitive) != 0) {
97 fileContent = QTextCodec::codecForName(qPrintable(to))
98 ->fromUnicode(contentStr.constData(), contentStr.size());
99 } else {
100 fileContent.clear();
101 fileContent.append(contentStr);
102 }
103
104 if (!f.open(QIODevice::WriteOnly)) return false;
105
106 f.write(fileContent);
107 f.close();
108
109 return true;
110}
111
112bool SubtitlePostProcessor::ppChangeSubtitlesEncoding(
113 const QString& subtitleFilePath, const QString& to) const {

Callers

nothing calls this directly

Calls 2

detectFileEncodingMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected