| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: qtextcodec.h 2 2005-11-16 15:49:26Z dmik $
|
|---|
| 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 | class QFont;
|
|---|
| 50 |
|
|---|
| 51 | class Q_EXPORT QTextEncoder {
|
|---|
| 52 | public:
|
|---|
| 53 | virtual ~QTextEncoder();
|
|---|
| 54 | virtual QCString fromUnicode(const QString& uc, int& lenInOut) = 0;
|
|---|
| 55 | };
|
|---|
| 56 |
|
|---|
| 57 | class Q_EXPORT QTextDecoder {
|
|---|
| 58 | public:
|
|---|
| 59 | virtual ~QTextDecoder();
|
|---|
| 60 | virtual QString toUnicode(const char* chars, int len) = 0;
|
|---|
| 61 | };
|
|---|
| 62 |
|
|---|
| 63 | class Q_EXPORT QTextCodec {
|
|---|
| 64 | public:
|
|---|
| 65 | virtual ~QTextCodec();
|
|---|
| 66 |
|
|---|
| 67 | #ifndef QT_NO_CODECS
|
|---|
| 68 | static QTextCodec* loadCharmap(QIODevice*);
|
|---|
| 69 | static QTextCodec* loadCharmapFile(QString filename);
|
|---|
| 70 | #endif //QT_NO_CODECS
|
|---|
| 71 | static QTextCodec* codecForMib(int mib);
|
|---|
| 72 | static QTextCodec* codecForName(const char* hint, int accuracy=0);
|
|---|
| 73 | static QTextCodec* codecForContent(const char* chars, int len);
|
|---|
| 74 | static QTextCodec* codecForIndex(int i);
|
|---|
| 75 | static QTextCodec* codecForLocale();
|
|---|
| 76 | static void setCodecForLocale(QTextCodec *c);
|
|---|
| 77 |
|
|---|
| 78 | static QTextCodec* codecForTr();
|
|---|
| 79 | static void setCodecForTr(QTextCodec *c);
|
|---|
| 80 | static QTextCodec* codecForCStrings();
|
|---|
| 81 | static void setCodecForCStrings(QTextCodec *c);
|
|---|
| 82 |
|
|---|
| 83 | static void deleteAllCodecs();
|
|---|
| 84 |
|
|---|
| 85 | static const char* locale();
|
|---|
| 86 |
|
|---|
| 87 | virtual const char* name() const = 0;
|
|---|
| 88 | virtual const char* mimeName() const;
|
|---|
| 89 | virtual int mibEnum() const = 0;
|
|---|
| 90 |
|
|---|
| 91 | virtual QTextDecoder* makeDecoder() const;
|
|---|
| 92 | virtual QTextEncoder* makeEncoder() const;
|
|---|
| 93 |
|
|---|
| 94 | virtual QString toUnicode(const char* chars, int len) const;
|
|---|
| 95 | virtual QCString fromUnicode(const QString& uc, int& lenInOut) const;
|
|---|
| 96 |
|
|---|
| 97 | QCString fromUnicode(const QString& uc) const;
|
|---|
| 98 | QString toUnicode(const QByteArray&, int len) const;
|
|---|
| 99 | QString toUnicode(const QByteArray&) const;
|
|---|
| 100 | QString toUnicode(const QCString&, int len) const;
|
|---|
| 101 | QString toUnicode(const QCString&) const;
|
|---|
| 102 | QString toUnicode(const char* chars) const;
|
|---|
| 103 | virtual bool canEncode( QChar ) const;
|
|---|
| 104 | virtual bool canEncode( const QString& ) const;
|
|---|
| 105 |
|
|---|
| 106 | virtual int heuristicContentMatch(const char* chars, int len) const = 0;
|
|---|
| 107 | virtual int heuristicNameMatch(const char* hint) const;
|
|---|
| 108 |
|
|---|
| 109 | virtual QByteArray fromUnicode(const QString& uc, int from, int len) const;
|
|---|
| 110 | virtual unsigned short characterFromUnicode(const QString &str, int pos) const;
|
|---|
| 111 |
|
|---|
| 112 | protected:
|
|---|
| 113 | QTextCodec();
|
|---|
| 114 | static int simpleHeuristicNameMatch(const char* name, const char* hint);
|
|---|
| 115 |
|
|---|
| 116 | private:
|
|---|
| 117 | friend class QFont;
|
|---|
| 118 | friend class QFontEngineXLFD;
|
|---|
| 119 | void fromUnicodeInternal( const QChar *in, unsigned short *out, int length );
|
|---|
| 120 |
|
|---|
| 121 | static QTextCodec *cftr;
|
|---|
| 122 | static QTextCodec *cfcs;
|
|---|
| 123 | };
|
|---|
| 124 |
|
|---|
| 125 | inline QTextCodec* QTextCodec::codecForTr() { return cftr; }
|
|---|
| 126 | inline void QTextCodec::setCodecForTr(QTextCodec *c) { cftr = c; }
|
|---|
| 127 | inline QTextCodec* QTextCodec::codecForCStrings() { return cfcs; }
|
|---|
| 128 | inline void QTextCodec::setCodecForCStrings(QTextCodec *c) { cfcs = c; }
|
|---|
| 129 |
|
|---|
| 130 | #endif // QT_NO_TEXTCODEC
|
|---|
| 131 | #endif // QTEXTCODEC_H
|
|---|