mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 21:20:19 +00:00
17fbb6b17f
Interpreting UTF8 encoded strings using tr() instead of trUtf8() and encoding the string back to utf8 again leads to serious encoding errors. Fixes #230 Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
27 lines
552 B
C++
27 lines
552 B
C++
#include <QCoreApplication>
|
|
#include <QString>
|
|
#include <gettextfromc.h>
|
|
|
|
const char *gettextFromC::trGettext(const char *text)
|
|
{
|
|
QByteArray &result = translationCache[QByteArray(text)];
|
|
if (result.isEmpty())
|
|
result = trUtf8(text).toUtf8();
|
|
return result.constData();
|
|
}
|
|
|
|
void gettextFromC::reset(void)
|
|
{
|
|
translationCache.clear();
|
|
}
|
|
|
|
gettextFromC* gettextFromC::instance()
|
|
{
|
|
static gettextFromC *self = new gettextFromC();
|
|
return self;
|
|
}
|
|
|
|
extern "C" const char *trGettext(const char *text)
|
|
{
|
|
return gettextFromC::instance()->trGettext(text);
|
|
}
|