/****************************************************************************
**
** Copyright (C) 1992-2004 Trolltech AS. All rights reserved.
**
** This file is part of the internationalization module of the Qt Toolkit.
**
** Licensees holding valid Qt Preview licenses may use this file in
** accordance with the Qt Preview License Agreement provided with the
** Software.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/

#include <qtextcodecplugin.h>
#include <qtextcodec.h>
#include <qstringlist.h>

#include <private/qgb18030codec_p.h>
#include <private/qfontcodecs_p.h>


class CNTextCodecs : public QTextCodecPlugin
{
public:
    CNTextCodecs() {}

    QStringList names() const  { return QStringList() << "GB18030" << "GBK" << "gb2312.1980-0" << "gbk-0"; }
    QList<int> mibEnums() const { return QList<int>() << -2025 << 57 << 2025; }

    QTextCodec *createForMib(int);
    QTextCodec *createForName(const QString &);
};

QTextCodec *CNTextCodecs::createForMib(int mib)
{
    switch (mib) {
    case 57:
        return new QGb2312Codec;
    case 2025:
        return new QGbkCodec;
    case -2025:
        return new QGb18030Codec;
    default:
        ;
    }

    return 0;
}


QTextCodec *CNTextCodecs::createForName(const QString &name)
{
    if (name == "GB18030")
        return new QGb18030Codec;
    if (name == "GBK" || name == "gbk-0")
        return new QGbkCodec;
    if (name == "gb2312.1980-0")
        return new QGb2312Codec;

    return 0;
}


Q_EXPORT_PLUGIN(CNTextCodecs);
