diff options
author | Chris Xiong <chirs241097@gmail.com> | 2023-11-26 21:29:16 -0500 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2023-11-26 21:29:16 -0500 |
commit | f7def0d883fa5cab62ef61b40b9f857245be8e6c (patch) | |
tree | d29322dd4be6e98c0740ae6df4dc70eb41614a76 /visualization/renderer/qmppluginapistub.cpp | |
parent | 60989e52b3f3bc0a95d3e61bd8e59fa4d9b7ab83 (diff) | |
download | QMidiPlayer-f7def0d883fa5cab62ef61b40b9f857245be8e6c.tar.xz |
Initial Qt 6 port. Many bug fixes.
Diffstat (limited to 'visualization/renderer/qmppluginapistub.cpp')
-rw-r--r-- | visualization/renderer/qmppluginapistub.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/visualization/renderer/qmppluginapistub.cpp b/visualization/renderer/qmppluginapistub.cpp index 7804cc6..c594f02 100644 --- a/visualization/renderer/qmppluginapistub.cpp +++ b/visualization/renderer/qmppluginapistub.cpp @@ -1,10 +1,11 @@ +#include <unicode/ustring.h> +#include <unicode/unistr.h> +#include <unicode/ucnv.h> #include "qmpmidiplay.hpp" #include "qmpvisrendercore.hpp" #include "qmpsettingsro.hpp" #include "qmppluginapistub.hpp" -#include <QTextCodec> - qmpPluginAPIStub::qmpPluginAPIStub(qmpVisRenderCore *_core): core(_core) { @@ -84,19 +85,24 @@ bool qmpPluginAPIStub::getChannelMask(int ch) } std::string qmpPluginAPIStub::getTitle() { - if (core->settings()->getOptionEnumIntOptName("Midi/TextEncoding") == "Unicode") - return std::string(core->player->getTitle()); - return QTextCodec::codecForName( - core->settings()->getOptionEnumIntOptName("Midi/TextEncoding").c_str())-> - toUnicode(core->player->getTitle()).toStdString(); + std::string enc(core->settings()->getOptionEnumIntOptName("Midi/TextEncoding")); + icu::UnicodeString us(core->player->getTitle(), enc.c_str()); + std::string r; + us.toUTF8String(r); + return r; } std::wstring qmpPluginAPIStub::getWTitle() { - if (core->settings()->getOptionEnumIntOptName("Midi/TextEncoding") == "Unicode") - return QString(core->player->getTitle()).toStdWString(); - return QTextCodec::codecForName( - core->settings()->getOptionEnumIntOptName("Midi/TextEncoding").c_str())-> - toUnicode(core->player->getTitle()).toStdWString(); + std::string enc(core->settings()->getOptionEnumIntOptName("Midi/TextEncoding")); + icu::UnicodeString us(core->player->getTitle(), enc.c_str()); + std::wstring r; + int32_t sz; + UErrorCode e = U_ZERO_ERROR; + u_strToWCS(nullptr, 0, &sz, us.getBuffer(), us.length(), &e); + r.resize(sz + 1); + e = U_ZERO_ERROR; + u_strToWCS(r.data(), r.size(), nullptr, us.getBuffer(), us.length(), &e); + return r; } std::string qmpPluginAPIStub::getFilePath() |