#include <KCharsets>

Public Member Functions

virtual ~KCharsets ()
QStringList availableEncodingNames () const
QTextCodeccodecForName (const QString &name) const
QTextCodeccodecForName (const QString &n, bool &ok) const
QString descriptionForEncoding (const QString &encoding) const
QStringList descriptiveEncodingNames () const
QString encodingForName (const QString &descriptiveName) const
QList< QStringListencodingsByScript () const

Static Public Member Functions

static KCharsetscharsets ()
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 33 of file kcharsets.h.

Constructor & Destructor Documentation

KCharsets::KCharsets ( )

Protected constructor.

If you need the kcharsets object, use KCharsets::charsets() instead.

Definition at line 514 of file kcharsets.cpp.

KCharsets::~KCharsets ( )


Member Function Documentation

QStringList KCharsets::availableEncodingNames ( ) const

Lists all available encodings as names.

the list of all encodings

Definition at line 637 of file kcharsets.cpp.

KCharsets * KCharsets::charsets ( )

The global charset manager.

the global charset manager

Definition at line 832 of file kcharsets.cpp.

QTextCodec * KCharsets::codecForName ( const QString name) const

Provided for compatibility.

namethe name of the codec
the QTextCodec. If the desired codec could not be found, it returns a default (ISO 8859-1) codec

Definition at line 716 of file kcharsets.cpp.

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.

nthe name of the codec
oktrue if a matching codec has been found, false if not
the QTextCodec. If the desired codec could not be found, it returns a default (ISO 8859-1) codec

Definition at line 730 of file kcharsets.cpp.

QString KCharsets::descriptionForEncoding ( const QString encoding) const

Returns a long description for an encoding name.

encodingthe encoding for the language
the long description for the encoding

Definition at line 647 of file kcharsets.cpp.

QStringList KCharsets::descriptiveEncodingNames ( ) const

Lists the available encoding names together with a more descriptive language.

the list of descriptive encoding names

Definition at line 679 of file kcharsets.cpp.

QString KCharsets::encodingForName ( const QString descriptiveName) const

Returns the encoding for a string obtained with descriptiveEncodingNames().

descriptiveNamethe descriptive name for the encoding
the name of the encoding

Definition at line 660 of file kcharsets.cpp.

QList< QStringList > KCharsets::encodingsByScript ( ) const

Lists the available encoding names grouped by script (or language that uses them).

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 691 of file kcharsets.cpp.

QChar KCharsets::fromEntity ( const QString str)

Converts an entity to a character.

The string must contain only the entity without the trailing ';'.

strthe entity
QChar::Null if the entity could not be decoded.

Definition at line 521 of file kcharsets.cpp.

QChar KCharsets::fromEntity ( const QString str,
int &  len 

Overloaded member function.

Tries to find an entity in the QString str.

strthe string containing entified
lenis a return value, that gives the length of the decoded entity.
a decoded entity if one could be found, QChar::null otherwise

Definition at line 567 of file kcharsets.cpp.

QString KCharsets::resolveEntities ( const QString text)

Scans the given string for entities (like &amp;) and resolves them using fromEntity.

textthe string containing the entities
the clean string

Definition at line 588 of file kcharsets.cpp.

QString KCharsets::toEntity ( const QChar ch)

Converts a QChar to an entity.

The returned string does already contain the leading '&' and the trailing ';'.

chthe char to convert
the entity

Definition at line 583 of file kcharsets.cpp.

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 16 2021 22:45:25 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.