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

KDECore

  • 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
29class QTextCodec;
30class QTextDecoder;
31class KEncodingDetectorPrivate;
32
58class KDECORE_EXPORT KEncodingDetector
59{
60public:
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
188protected:
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
215private:
216 KEncodingDetectorPrivate* const d;
217};
218
219#endif
KEncodingDetector
Provides encoding detection capabilities.
Definition: kencodingdetector.h:59
KEncodingDetector::AutoDetectScript
AutoDetectScript
Definition: kencodingdetector.h:73
KEncodingDetector::None
@ None
Definition: kencodingdetector.h:74
KEncodingDetector::Korean
@ Korean
Definition: kencodingdetector.h:85
KEncodingDetector::CentralEuropean
@ CentralEuropean
Definition: kencodingdetector.h:78
KEncodingDetector::Thai
@ Thai
Definition: kencodingdetector.h:88
KEncodingDetector::Japanese
@ Japanese
Definition: kencodingdetector.h:84
KEncodingDetector::SemiautomaticDetection
@ SemiautomaticDetection
Definition: kencodingdetector.h:75
KEncodingDetector::Hebrew
@ Hebrew
Definition: kencodingdetector.h:83
KEncodingDetector::Greek
@ Greek
Definition: kencodingdetector.h:82
KEncodingDetector::Cyrillic
@ Cyrillic
Definition: kencodingdetector.h:81
KEncodingDetector::Turkish
@ Turkish
Definition: kencodingdetector.h:89
KEncodingDetector::Unicode
@ Unicode
Definition: kencodingdetector.h:90
KEncodingDetector::SouthEasternEurope
@ SouthEasternEurope
Definition: kencodingdetector.h:87
KEncodingDetector::NorthernSaami
@ NorthernSaami
Definition: kencodingdetector.h:86
KEncodingDetector::Arabic
@ Arabic
Definition: kencodingdetector.h:76
KEncodingDetector::ChineseTraditional
@ ChineseTraditional
Definition: kencodingdetector.h:80
KEncodingDetector::ChineseSimplified
@ ChineseSimplified
Definition: kencodingdetector.h:79
KEncodingDetector::Baltic
@ Baltic
Definition: kencodingdetector.h:77
KEncodingDetector::EncodingChoiceSource
EncodingChoiceSource
Definition: kencodingdetector.h:62
KEncodingDetector::BOM
@ BOM
Definition: kencodingdetector.h:65
KEncodingDetector::AutoDetectedEncoding
@ AutoDetectedEncoding
Definition: kencodingdetector.h:64
KEncodingDetector::EncodingFromXMLHeader
@ EncodingFromXMLHeader
Definition: kencodingdetector.h:66
KEncodingDetector::EncodingFromHTTPHeader
@ EncodingFromHTTPHeader
Definition: kencodingdetector.h:68
KEncodingDetector::DefaultEncoding
@ DefaultEncoding
Definition: kencodingdetector.h:63
KEncodingDetector::EncodingFromMetaTag
@ EncodingFromMetaTag
Definition: kencodingdetector.h:67
QString
kdecore_export.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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