khtml Library API Documentation

decoder.h

00001 /*
00002     This file is part of the KDE libraries
00003 
00004     Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de)
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019     Boston, MA 02111-1307, USA.
00020 
00021     $Id: decoder.h,v 1.14.10.1 2003/05/18 12:34:39 mueller Exp $
00022 */
00023 #ifndef KHTMLDECODER_H
00024 #define KHTMLDECODER_H
00025 
00026 #include <qstring.h>
00027 class QTextCodec;
00028 class QTextDecoder;
00029 
00030 namespace khtml {
00034 class Decoder
00035 {
00036 public:
00037     Decoder();
00038     ~Decoder();
00039 
00040     void setEncoding(const char *encoding, bool force = false);
00041     const char *encoding() const;
00042 
00043     QString decode(const char *data, int len);
00044 
00045     bool visuallyOrdered() const { return visualRTL; }
00046 
00047     const QTextCodec *codec() const { return m_codec; }
00048 
00049     QString flush() const;
00050 
00051     enum AutomaticDetectinonLanguage {
00052         SemiautomaticDetection,
00053         Arabic,
00054         Baltic,
00055         CentralEuropean,
00056         Chinese,
00057         Greek,
00058         Hebrew,
00059         Japanese,
00060         Korean,
00061         Russian,
00062         Thai,
00063         Turkish,
00064         Ukrainian,
00065         Unicode,
00066         WesternEuropean
00067     };
00068 
00069     void setAutomaticDetectionLanguage( AutomaticDetectinonLanguage _language ) { m_automaticDetectionLanguage = _language; }
00070     AutomaticDetectinonLanguage automaticDetectionLanguage() { return m_automaticDetectionLanguage; }
00071 
00072 
00073 protected:
00074     QCString automaticDetectionForArabic( const char* str );
00075     QCString automaticDetectionForBaltic( const char* str );
00076     QCString automaticDetectionForCentralEuropean( const char* str );
00077     QCString automaticDetectionForCyrillic( const char* str, AutomaticDetectinonLanguage _language );
00078     QCString automaticDetectionForGreek( const char* str );
00079     QCString automaticDetectionForHebrew( const char* str );
00080     QCString automaticDetectionForTurkish( const char* str );
00081     QCString automaticDetectionForWesternEuropean( const char* str );
00082 
00083 
00084     // codec used for decoding. default is Latin1.
00085     QTextCodec *m_codec;
00086     QTextDecoder *m_decoder; // only used for utf16
00087     QCString enc;
00088 
00089     QCString buffer;
00090 
00091     bool body;
00092     bool beginning;
00093     bool visualRTL;
00094     bool haveEncoding;
00095 
00096     AutomaticDetectinonLanguage m_automaticDetectionLanguage;
00097 };
00098 
00099 }
00100 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Mar 20 11:20:01 2005 by doxygen 1.3.3 written by Dimitri van Heesch, © 1997-2001