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

Method ppReplaceDiacriticsWithASCII

libqnapi/src/subtitlepostprocessor.cpp:56–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56bool SubtitlePostProcessor::ppReplaceDiacriticsWithASCII(
57 const QString& subtitleFilePath) const {
58 if (!QFileInfo(subtitleFilePath).exists()) return false;
59
60 QString from = encodingUtils.detectFileEncoding(subtitleFilePath);
61
62 if (from.isEmpty()) return false;
63
64 QFile f(subtitleFilePath);
65 if (!f.open(QIODevice::ReadOnly)) return false;
66
67 QByteArray fileContent = f.readAll();
68
69 QString contentStr =
70 QTextCodec::codecForName(qPrintable(from))->toUnicode(fileContent);
71 f.close();
72
73 fileContent.clear();
74 fileContent.append(encodingUtils.replaceDiacriticsWithASCII(contentStr));
75
76 if (!f.open(QIODevice::WriteOnly)) return false;
77
78 f.write(fileContent);
79 f.close();
80
81 return true;
82}
83
84bool SubtitlePostProcessor::ppChangeSubtitlesEncoding(
85 const QString& subtitleFilePath, const QString& from,

Callers

nothing calls this directly

Calls 3

detectFileEncodingMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected