|
1 /**************************************************************************** |
|
2 ** |
|
3 ** |
|
4 ** Definition of QTextCodec class |
|
5 ** |
|
6 ** Created : 981015 |
|
7 ** |
|
8 ** Copyright (C) 1998-2000 Trolltech AS. All rights reserved. |
|
9 ** |
|
10 ** This file is part of the tools module of the Qt GUI Toolkit. |
|
11 ** |
|
12 ** This file may be distributed under the terms of the Q Public License |
|
13 ** as defined by Trolltech AS of Norway and appearing in the file |
|
14 ** LICENSE.QPL included in the packaging of this file. |
|
15 ** |
|
16 ** This file may be distributed and/or modified under the terms of the |
|
17 ** GNU General Public License version 2 as published by the Free Software |
|
18 ** Foundation and appearing in the file LICENSE.GPL included in the |
|
19 ** packaging of this file. |
|
20 ** |
|
21 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition |
|
22 ** licenses may use this file in accordance with the Qt Commercial License |
|
23 ** Agreement provided with the Software. |
|
24 ** |
|
25 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
|
26 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
|
27 ** |
|
28 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
|
29 ** information about Qt Commercial License Agreements. |
|
30 ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
|
31 ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
|
32 ** |
|
33 ** Contact info@trolltech.com if any conditions of this licensing are |
|
34 ** not clear to you. |
|
35 ** |
|
36 **********************************************************************/ |
|
37 |
|
38 #ifndef QTEXTCODEC_H |
|
39 #define QTEXTCODEC_H |
|
40 |
|
41 #ifndef QT_H |
|
42 #include "qstring.h" |
|
43 #endif // QT_H |
|
44 |
|
45 #ifndef QT_NO_TEXTCODEC |
|
46 |
|
47 class QTextCodec; |
|
48 class QIODevice; |
|
49 |
|
50 class Q_EXPORT QTextEncoder { |
|
51 public: |
|
52 virtual ~QTextEncoder(); |
|
53 virtual QCString fromUnicode(const QString& uc, int& lenInOut) = 0; |
|
54 }; |
|
55 |
|
56 class Q_EXPORT QTextDecoder { |
|
57 public: |
|
58 virtual ~QTextDecoder(); |
|
59 virtual QString toUnicode(const char* chars, int len) = 0; |
|
60 }; |
|
61 |
|
62 class Q_EXPORT QTextCodec { |
|
63 public: |
|
64 virtual ~QTextCodec(); |
|
65 |
|
66 #ifndef QT_NO_CODECS |
|
67 static QTextCodec* loadCharmap(QIODevice*); |
|
68 static QTextCodec* loadCharmapFile(QString filename); |
|
69 #endif |
|
70 static QTextCodec* codecForMib(int mib); |
|
71 static QTextCodec* codecForName(const char* hint, int accuracy=0); |
|
72 static QTextCodec* codecForContent(const char* chars, int len); |
|
73 static QTextCodec* codecForIndex(int i); |
|
74 static QTextCodec* codecForLocale(); |
|
75 |
|
76 static void deleteAllCodecs(); |
|
77 |
|
78 static const char* locale(); |
|
79 |
|
80 virtual const char* name() const = 0; |
|
81 virtual int mibEnum() const = 0; |
|
82 |
|
83 virtual QTextDecoder* makeDecoder() const; |
|
84 virtual QTextEncoder* makeEncoder() const; |
|
85 |
|
86 virtual QString toUnicode(const char* chars, int len) const; |
|
87 virtual QCString fromUnicode(const QString& uc, int& lenInOut) const; |
|
88 |
|
89 QCString fromUnicode(const QString& uc) const; |
|
90 QString toUnicode(const QByteArray&, int len) const; |
|
91 QString toUnicode(const QByteArray&) const; |
|
92 QString toUnicode(const char* chars) const; |
|
93 virtual bool canEncode( QChar ) const; |
|
94 virtual bool canEncode( const QString& ) const; |
|
95 |
|
96 virtual int heuristicContentMatch(const char* chars, int len) const = 0; |
|
97 virtual int heuristicNameMatch(const char* hint) const; |
|
98 |
|
99 protected: |
|
100 QTextCodec(); |
|
101 static int simpleHeuristicNameMatch(const char* name, const char* hint); |
|
102 }; |
|
103 #endif // QT_NO_TEXTCODEC |
|
104 #endif // QTEXTCODEC_H |