| 54 | } |
| 55 | |
| 56 | bool 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 | |
| 84 | bool SubtitlePostProcessor::ppChangeSubtitlesEncoding( |
| 85 | const QString& subtitleFilePath, const QString& from, |
nothing calls this directly
no test coverage detected