KDECore
kencodingprober.h
Go to the documentation of this file.
00001 /* 00002 This file is part of the KDE libraries 00003 00004 Copyright (C) 2008 Wang Hoi (zealot.hoi@gmail.com) 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., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 00021 */ 00022 #ifndef KENCODINGPROBER_H 00023 #define KENCODINGPROBER_H 00024 00025 // enable debug of private probers 00026 // #define DEBUG_PROBE 00027 00028 #include <kdecore_export.h> 00029 #ifdef DEBUG_PROBE 00030 #include <kdebug.h> 00031 #endif 00032 #include <QtCore/QString> 00033 00034 class KEncodingProberPrivate; 00035 00067 class KDECORE_EXPORT KEncodingProber 00068 { 00069 public: 00070 00071 enum ProberState { 00072 FoundIt, 00073 NotMe, 00074 Probing 00075 }; 00076 00077 enum ProberType { 00078 None, 00079 Universal, 00080 Arabic, 00081 Baltic, 00082 CentralEuropean, 00083 ChineseSimplified, 00084 ChineseTraditional, 00085 Cyrillic, 00086 Greek, 00087 Hebrew, 00088 Japanese, 00089 Korean, 00090 NorthernSaami, 00091 Other, 00092 SouthEasternEurope, 00093 Thai, 00094 Turkish, 00095 Unicode, 00096 WesternEuropean 00097 }; 00098 00102 KEncodingProber(ProberType proberType=Universal); 00103 00104 ~KEncodingProber(); 00105 00109 void reset(); 00110 00118 ProberState feed(const QByteArray &data); 00119 ProberState feed(const char* data, int len); 00120 00125 ProberState state() const; 00126 00132 #ifndef KDE_NO_DEPRECATED 00133 KDE_DEPRECATED const char* encodingName() const; 00134 #endif 00135 00140 QByteArray encoding() const; 00141 00145 float confidence() const; 00146 00147 ProberType proberType() const; 00148 00152 void setProberType(ProberType proberType); 00153 00157 static ProberType proberTypeForName(const QString& lang); 00158 00162 static QString nameForProberType(ProberType proberType); 00163 00164 private: 00165 KEncodingProberPrivate* const d; 00166 }; 00167 00168 #endif
KDE 4.6 API Reference