• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • kdecore
  • localization
kencodingdetector.h
Go to the documentation of this file.
1 /*
2  This file is part of the KDE libraries
3 
4  Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de)
5  Copyright (C) 2007 Nick Shaforostoff (shafff@ukr.net)
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 
22 */
23 #ifndef KENCODINGDETECTOR_H
24 #define KENCODINGDETECTOR_H
25 
26 #include <kdecore_export.h>
27 #include <QtCore/QString>
28 
29 class QTextCodec;
30 class QTextDecoder;
31 class KEncodingDetectorPrivate;
32 
58 class KDECORE_EXPORT KEncodingDetector
59 {
60 public:
61  enum EncodingChoiceSource
62  {
63  DefaultEncoding,
64  AutoDetectedEncoding,
65  BOM,
66  EncodingFromXMLHeader,
67  EncodingFromMetaTag,
68  EncodingFromHTTPHeader,
69  UserChosenEncoding
70  };
71 
72  enum AutoDetectScript
73  {
74  None,
75  SemiautomaticDetection,
76  Arabic,
77  Baltic,
78  CentralEuropean,
79  ChineseSimplified,
80  ChineseTraditional,
81  Cyrillic,
82  Greek,
83  Hebrew,
84  Japanese,
85  Korean,
86  NorthernSaami,
87  SouthEasternEurope,
88  Thai,
89  Turkish,
90  Unicode,
91  WesternEuropean
92  };
93 
97  KEncodingDetector();
98 
102  KEncodingDetector(QTextCodec* codec, EncodingChoiceSource source, AutoDetectScript script=None);
103  ~KEncodingDetector();
104 
105  //const QTextCodec* codec() const;
106 
110  bool setEncoding(const char *encoding, EncodingChoiceSource type);
111 
116  const char* encoding() const;
117 
118  bool visuallyOrdered() const;
119 
120 // void setAutoDetectLanguage( const QString& );
121 // const QString& autoDetectLanguage() const;
122 
123  void setAutoDetectLanguage( AutoDetectScript );
124  AutoDetectScript autoDetectLanguage() const;
125 
126  EncodingChoiceSource encodingChoiceSource() const;
127 
135  QString decode(const char *data, int len);
136  QString decode(const QByteArray &data);
137 
138  //* You don't need to call analyze() if you use this method.
148  QString decodeWithBuffering(const char *data, int len);
149 
162  bool decodedInvalidCharacters() const;
163 
173  void resetDecoder();
174 
179  QString flush();
180 
184  static AutoDetectScript scriptForName(const QString& lang);
185  static QString nameForScript(AutoDetectScript);
186  static bool hasAutoDetectionForScript(AutoDetectScript);
187 
188 protected:
193  bool processNull(char* data,int length);
194 
202  bool errorsIfUtf8 (const char* data, int length);
203 
208  bool analyze (const char *data, int len);
209 
213  QTextDecoder* decoder();
214 
215 private:
216  KEncodingDetectorPrivate* const d;
217 };
218 
219 #endif
KEncodingDetector::ChineseSimplified
Definition: kencodingdetector.h:79
KEncodingDetector::AutoDetectedEncoding
Definition: kencodingdetector.h:64
KEncodingDetector::Japanese
Definition: kencodingdetector.h:84
KEncodingDetector::Arabic
Definition: kencodingdetector.h:76
KEncodingDetector::ChineseTraditional
Definition: kencodingdetector.h:80
KEncodingDetector::Korean
Definition: kencodingdetector.h:85
KEncodingDetector
Provides encoding detection capabilities.
Definition: kencodingdetector.h:58
kdecore_export.h
QByteArray
KEncodingDetector::DefaultEncoding
Definition: kencodingdetector.h:63
KEncodingDetector::EncodingChoiceSource
EncodingChoiceSource
Definition: kencodingdetector.h:61
KEncodingDetector::Cyrillic
Definition: kencodingdetector.h:81
KEncodingDetector::EncodingFromMetaTag
Definition: kencodingdetector.h:67
KEncodingDetector::AutoDetectScript
AutoDetectScript
Definition: kencodingdetector.h:72
KEncodingDetector::Baltic
Definition: kencodingdetector.h:77
Kuit::Tag::None
Definition: kuitsemantics.cpp:82
KEncodingDetector::EncodingFromHTTPHeader
Definition: kencodingdetector.h:68
KEncodingDetector::Greek
Definition: kencodingdetector.h:82
QString
QTextCodec
KEncodingDetector::NorthernSaami
Definition: kencodingdetector.h:86
KEncodingDetector::SemiautomaticDetection
Definition: kencodingdetector.h:75
KEncodingDetector::BOM
Definition: kencodingdetector.h:65
KEncodingDetector::EncodingFromXMLHeader
Definition: kencodingdetector.h:66
KEncodingDetector::CentralEuropean
Definition: kencodingdetector.h:78
KEncodingDetector::Hebrew
Definition: kencodingdetector.h:83
KEncodingDetector::SouthEasternEurope
Definition: kencodingdetector.h:87
QTextDecoder
KEncodingDetector::Thai
Definition: kencodingdetector.h:88
KEncodingDetector::None
Definition: kencodingdetector.h:74
KEncodingDetector::Turkish
Definition: kencodingdetector.h:89
KEncodingDetector::Unicode
Definition: kencodingdetector.h:90
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal