source: trunk/plugins/src/codecs/cn/main.cpp

Last change on this file was 204, checked in by rudi, 14 years ago

Added plugin source code

File size: 1.1 KB
Line 
1#include <qtextcodecplugin.h>
2#include <qtextcodec.h>
3#include <qptrlist.h>
4#include <qapplication.h>
5
6#include <qgb18030codec.h>
7#include <private/qfontcodecs_p.h>
8
9
10class CNTextCodecs : public QTextCodecPlugin
11{
12public:
13 CNTextCodecs() {}
14
15 QStringList names() const { return QStringList() << "GB18030" << "GBK" << "gb2312.1980-0" << "gbk-0"; }
16 QValueList<int> mibEnums() const { return QValueList<int>() << -2025 << 57 << 2025; }
17
18 QTextCodec *createForMib( int );
19 QTextCodec *createForName( const QString & );
20};
21
22QTextCodec *CNTextCodecs::createForMib( int mib )
23{
24 switch (mib) {
25 case 57:
26 return new QGb2312Codec;
27 case 2025:
28 return new QGbkCodec;
29 case -2025:
30 return new QGb18030Codec;
31 default:
32 ;
33 }
34
35 return 0;
36}
37
38
39QTextCodec *CNTextCodecs::createForName( const QString &name )
40{
41 if (name == "GB18030")
42 return new QGb18030Codec;
43 if (name == "GBK" || name == "gbk-0")
44 return new QGbkCodec;
45 if (name == "gb2312.1980-0")
46 return new QGb2312Codec;
47
48 return 0;
49}
50
51
52Q_EXPORT_PLUGIN( CNTextCodecs );
Note: See TracBrowser for help on using the repository browser.