aboutsummaryrefslogtreecommitdiff
path: root/visualization/renderer/qmppluginapistub.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'visualization/renderer/qmppluginapistub.cpp')
-rw-r--r--visualization/renderer/qmppluginapistub.cpp30
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()