Moved available_codepages() function into MUtilities library.
This commit is contained in:
parent
a90d30c71e
commit
77219cf7d4
@ -95,6 +95,8 @@ namespace MUtils
|
||||
MUTILS_API QString clean_file_name(const QString &name);
|
||||
MUTILS_API QString clean_file_path(const QString &path);
|
||||
|
||||
MUTILS_API QStringList available_codepages(const bool &noAliases = true);
|
||||
|
||||
//Internal
|
||||
namespace Internal
|
||||
{
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <QDir>
|
||||
#include <QReadWriteLock>
|
||||
#include <QProcess>
|
||||
#include <QTextCodec>
|
||||
|
||||
//CRT
|
||||
#include <cstdlib>
|
||||
@ -378,6 +379,38 @@ QString MUtils::clean_file_path(const QString &path)
|
||||
return parts.join("/");
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// AVAILABLE CODEPAGES
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QStringList MUtils::available_codepages(const bool &noAliases)
|
||||
{
|
||||
QStringList codecList;
|
||||
QList<QByteArray> availableCodecs = QTextCodec::availableCodecs();
|
||||
|
||||
while(!availableCodecs.isEmpty())
|
||||
{
|
||||
const QByteArray current = availableCodecs.takeFirst();
|
||||
if(!current.toLower().startsWith("system"))
|
||||
{
|
||||
codecList << QString::fromLatin1(current.constData(), current.size());
|
||||
if(noAliases)
|
||||
{
|
||||
if(QTextCodec *const currentCodec = QTextCodec::codecForName(current.constData()))
|
||||
{
|
||||
const QList<QByteArray> aliases = currentCodec->aliases();
|
||||
for(QList<QByteArray>::ConstIterator iter = aliases.constBegin(); iter != aliases.constEnd(); iter++)
|
||||
{
|
||||
availableCodecs.removeAll(*iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return codecList;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// SELF-TEST
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user