Qt 4.8
qgb18030codec.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 // Contributed by James Su <suzhe@gnuchina.org>
43 
44 #ifndef QGB18030CODEC_H
45 #define QGB18030CODEC_H
46 
47 #include <QtCore/qtextcodec.h>
48 #include <QtCore/qlist.h>
49 
51 
52 #ifndef QT_NO_TEXTCODEC
53 
54 class QGb18030Codec : public QTextCodec {
55 public:
56  QGb18030Codec();
57 
58  static QByteArray _name() { return "GB18030"; }
60  static int _mibEnum() { return 114; }
61 
62  QByteArray name() const { return _name(); }
63  QList<QByteArray> aliases() const { return _aliases(); }
64  int mibEnum() const { return _mibEnum(); }
65 
66  QString convertToUnicode(const char *, int, ConverterState *) const;
67  QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const;
68 };
69 
70 class QGbkCodec : public QGb18030Codec {
71 public:
72  QGbkCodec();
73 
74  static QByteArray _name();
75  static QList<QByteArray> _aliases();
76  static int _mibEnum();
77 
78  QByteArray name() const { return _name(); }
79  QList<QByteArray> aliases() const { return _aliases(); }
80  int mibEnum() const { return _mibEnum(); }
81 
82  QString convertToUnicode(const char *, int, ConverterState *) const;
83  QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const;
84 };
85 
86 class QGb2312Codec : public QGb18030Codec {
87 public:
88  QGb2312Codec();
89 
90  static QByteArray _name();
92  static int _mibEnum();
93 
94  QByteArray name() const { return _name(); }
95  int mibEnum() const { return _mibEnum(); }
96 
97  QString convertToUnicode(const char *, int, ConverterState *) const;
98  QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const;
99 };
100 
101 #ifdef Q_WS_X11
102 
104 {
105 public:
107 
108  static QByteArray _name();
110  static int _mibEnum();
111 
112  QByteArray name() const { return _name(); }
113  int mibEnum() const { return _mibEnum(); }
114 
115  QString convertToUnicode(const char *, int, ConverterState *) const;
116  QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const;
117 };
118 
119 
120 class QFontGbkCodec : public QTextCodec
121 {
122 public:
123  QFontGbkCodec();
124 
125  static QByteArray _name();
127  static int _mibEnum();
128 
129  QByteArray name() const { return _name(); }
130  QList<QByteArray> aliases() const { return _aliases(); }
131  int mibEnum() const { return _mibEnum(); }
132 
133  QString convertToUnicode(const char *, int, ConverterState *) const;
134  QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const;
135 };
136 
138 {
139 public:
141 
142  static QByteArray _name();
144  static int _mibEnum();
145 
146  QByteArray name() const { return _name(); }
147  QList<QByteArray> aliases() const { return _aliases(); }
148  int mibEnum() const { return _mibEnum(); }
149 
150  QString convertToUnicode(const char *, int, ConverterState *) const;
151  QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const;
152 };
153 #endif // Q_WS_X11
154 
155 #endif // QT_NO_TEXTCODEC
156 
158 
159 #endif // QGB18030CODEC_H
QList< QByteArray > aliases() const
Subclasses can return a number of aliases for the codec in question.
int mibEnum() const
Subclasses of QTextCodec must reimplement this function.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QByteArray name() const
QTextCodec subclasses must reimplement this function.
int mibEnum() const
Subclasses of QTextCodec must reimplement this function.
int mibEnum() const
Subclasses of QTextCodec must reimplement this function.
Definition: qgb18030codec.h:95
QList< QByteArray > aliases() const
Subclasses can return a number of aliases for the codec in question.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QByteArray name() const
QTextCodec subclasses must reimplement this function.
Definition: qgb18030codec.h:94
QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const
Reimplemented Function
int mibEnum() const
Subclasses of QTextCodec must reimplement this function.
Definition: qgb18030codec.h:64
QList< QByteArray > aliases() const
Subclasses can return a number of aliases for the codec in question.
Definition: qgb18030codec.h:79
QList< QByteArray > aliases() const
Subclasses can return a number of aliases for the codec in question.
Definition: qgb18030codec.h:63
QByteArray name() const
QTextCodec subclasses must reimplement this function.
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QList< QByteArray > _aliases()
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QByteArray name() const
QTextCodec subclasses must reimplement this function.
Definition: qgb18030codec.h:78
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static int _mibEnum()
Definition: qgb18030codec.h:60
static QList< QByteArray > _aliases()
static QList< QByteArray > _aliases()
Definition: qgb18030codec.h:91
static QByteArray _name()
Definition: qgb18030codec.h:58
QByteArray name() const
QTextCodec subclasses must reimplement this function.
QString convertToUnicode(const char *, int, ConverterState *) const
QTextCodec subclasses must reimplement this function.
static QList< QByteArray > _aliases()
Definition: qgb18030codec.h:59
The QGbkCodec class provides conversion to and from the Chinese GBK encoding.
Definition: qgb18030codec.h:70
int mibEnum() const
Subclasses of QTextCodec must reimplement this function.
Definition: qgb18030codec.h:80
QByteArray name() const
QTextCodec subclasses must reimplement this function.
Definition: qgb18030codec.h:62
The QTextCodec class provides conversions between text encodings.
Definition: qtextcodec.h:62
static QList< QByteArray > _aliases()
int mibEnum() const
Subclasses of QTextCodec must reimplement this function.
The QGb2312Codec class provides conversion to and from the Chinese GB2312 encoding.
Definition: qgb18030codec.h:86