KCharsets
#include <KCharsets>
Public Member Functions | |
virtual | ~KCharsets () |
QStringList | availableEncodingNames () const |
QTextCodec * | codecForName (const QString &n, bool &ok) const |
QTextCodec * | codecForName (const QString &name) const |
QString | descriptionForEncoding (const QString &encoding) const |
QStringList | descriptiveEncodingNames () const |
QString | encodingForName (const QString &descriptiveName) const |
QList< QStringList > | encodingsByScript () const |
Static Public Member Functions | |
static KCharsets * | charsets () |
static QChar | fromEntity (const QString &str) |
static QChar | fromEntity (const QString &str, int &len) |
static QString | resolveEntities (const QString &text) |
static QString | toEntity (const QChar &ch) |
Protected Member Functions | |
KCharsets () | |
Detailed Description
Charset font and encoder/decoder handling.
This is needed, because Qt's encoding name matching in QTextCodec::codecForName matches only closely-related encoded names but not alternate names, e.g. found in the reality of the Internet.
Definition at line 41 of file kcharsets.h.
Constructor & Destructor Documentation
◆ KCharsets()
|
protected |
Protected constructor.
If you need the kcharsets object, use KCharsets::charsets() instead.
Definition at line 485 of file kcharsets.cpp.
◆ ~KCharsets()
|
virtualdefault |
Destructor.
Member Function Documentation
◆ availableEncodingNames()
QStringList KCharsets::availableEncodingNames | ( | ) | const |
Lists all available encodings as names.
- Returns
- the list of all encodings
Definition at line 608 of file kcharsets.cpp.
◆ charsets()
|
static |
The global charset manager.
- Returns
- the global charset manager
Definition at line 835 of file kcharsets.cpp.
◆ codecForName() [1/2]
QTextCodec * KCharsets::codecForName | ( | const QString & | n, |
bool & | ok | ||
) | const |
Tries to find a QTextCodec to convert the given encoding from and to Unicode.
If no codec could be found, the ISO 8859-1 codec will be returned an and ok
will be set to false.
- Deprecated:
- apps should use QTextCodec::codecForName in Qt5 or Qt5Compat in Qt6 or port to QStringEncoder
- Parameters
-
n the name of the codec ok true if a matching codec has been found, false if not
- Returns
- the QTextCodec. If the desired codec could not be found, it returns a default (ISO 8859-1) codec
Definition at line 705 of file kcharsets.cpp.
◆ codecForName() [2/2]
QTextCodec * KCharsets::codecForName | ( | const QString & | name | ) | const |
Provided for compatibility.
- Parameters
-
name the name of the codec
- Returns
- the QTextCodec. If the desired codec could not be found, it returns a default (ISO 8859-1) codec
- Deprecated:
- since 5.101 apps should use QTextCodec::codecForName in Qt5 or Qt5Compat in Qt6 or port to QStringEncoder
Definition at line 684 of file kcharsets.cpp.
◆ descriptionForEncoding()
Returns a long description for an encoding name.
- Parameters
-
encoding the encoding for the language
- Returns
- the long description for the encoding
Definition at line 618 of file kcharsets.cpp.
◆ descriptiveEncodingNames()
QStringList KCharsets::descriptiveEncodingNames | ( | ) | const |
Lists the available encoding names together with a more descriptive language.
- Returns
- the list of descriptive encoding names
Definition at line 647 of file kcharsets.cpp.
◆ encodingForName()
Returns the encoding for a string obtained with descriptiveEncodingNames().
- Parameters
-
descriptiveName the descriptive name for the encoding
- Returns
- the name of the encoding
Definition at line 628 of file kcharsets.cpp.
◆ encodingsByScript()
QList< QStringList > KCharsets::encodingsByScript | ( | ) | const |
Lists the available encoding names grouped by script (or language that uses them).
- Returns
- the list of lists consisting of description followed by encoding names (i.e. encodingsByScript().at(i).at(0) is a description for encodingsByScript().at(i).at(k), k>0)
Definition at line 659 of file kcharsets.cpp.
◆ fromEntity() [1/2]
Converts an entity to a character.
The string must contain only the entity without the trailing ';'.
- Parameters
-
str the entity
- Returns
- QChar::Null if the entity could not be decoded.
Definition at line 492 of file kcharsets.cpp.
◆ fromEntity() [2/2]
Overloaded member function.
Tries to find an entity in the QString str.
- Parameters
-
str the string containing entified len is a return value, that gives the length of the decoded entity.
- Returns
- a decoded entity if one could be found, QChar::null otherwise
Definition at line 538 of file kcharsets.cpp.
◆ resolveEntities()
Scans the given string for entities (like &) and resolves them using fromEntity.
- Parameters
-
text the string containing the entities
- Returns
- the clean string
Definition at line 559 of file kcharsets.cpp.
◆ toEntity()
Converts a QChar to an entity.
The returned string does already contain the leading '&' and the trailing ';'.
- Parameters
-
ch the char to convert
- Returns
- the entity
Definition at line 554 of file kcharsets.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Dec 5 2023 04:00:55 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.