Add a factory method to QIsciiCodec and fix the names

Make the names all lower case to be in line with what ICU
reports. Add a factory method to create the codecs according
to their name.

Change-Id: Ia3dddaa7701a0645d9d8fbcb52f1f8d58f79cf98
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Lars Knoll 2012-07-25 12:54:56 +02:00 committed by Qt by Nokia
parent b23f048cf9
commit bb3637d33c
2 changed files with 21 additions and 9 deletions

View File

@ -39,6 +39,7 @@
**
****************************************************************************/
#include "qisciicodec_p.h"
#include "qtextcodec_p.h"
#include "qlist.h"
#ifndef QT_NO_BIG_CODECS
@ -59,17 +60,26 @@ struct Codecs {
};
static const Codecs codecs [] = {
{ "Iscii-Dev", 0x900 },
{ "Iscii-Bng", 0x980 },
{ "Iscii-Pnj", 0xa00 },
{ "Iscii-Gjr", 0xa80 },
{ "Iscii-Ori", 0xb00 },
{ "Iscii-Tml", 0xb80 },
{ "Iscii-Tlg", 0xc00 },
{ "Iscii-Knd", 0xc80 },
{ "Iscii-Mlm", 0xd00 }
{ "iscii-dev", 0x900 },
{ "iscii-bng", 0x980 },
{ "iscii-pnj", 0xa00 },
{ "iscii-gjr", 0xa80 },
{ "iscii-ori", 0xb00 },
{ "iscii-tml", 0xb80 },
{ "iscii-tlg", 0xc00 },
{ "iscii-knd", 0xc80 },
{ "iscii-mlm", 0xd00 }
};
QTextCodec *QIsciiCodec::create(const char *name)
{
for (int i = 0; i < 9; ++i) {
if (!qstricmp(name, codecs[i].name))
return new QIsciiCodec(i);
}
return 0;
}
QIsciiCodec::~QIsciiCodec()
{
}

View File

@ -64,6 +64,8 @@ public:
explicit QIsciiCodec(int i) : idx(i) {}
~QIsciiCodec();
static QTextCodec *create(const char *name);
QByteArray name() const;
int mibEnum() const;