KCharsets

Search for usage in LXR

#include <KCharsets>

Public Member Functions

 ~KCharsets ()
 
QStringList availableEncodingNames () const
 
QString descriptionForEncoding (QStringView encoding) const
 
QStringList descriptiveEncodingNames () const
 
QString encodingForName (const QString &descriptiveName) const
 
QList< QStringListencodingsByScript () const
 

Static Public Member Functions

static KCharsetscharsets ()
 
static QChar fromEntity (QStringView str)
 
static QChar fromEntity (QStringView 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::KCharsets ( )
protected

Protected constructor.

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

Definition at line 245 of file kcharsets.cpp.

◆ ~KCharsets()

KCharsets::~KCharsets ( )
default

Destructor.

Member Function Documentation

◆ availableEncodingNames()

QStringList KCharsets::availableEncodingNames ( ) const

Lists all available encodings as names.

Returns
the list of all encodings

Definition at line 368 of file kcharsets.cpp.

◆ charsets()

KCharsets * KCharsets::charsets ( )
static

The global charset manager.

Returns
the global charset manager

Definition at line 443 of file kcharsets.cpp.

◆ descriptionForEncoding()

QString KCharsets::descriptionForEncoding ( QStringView encoding) const

Returns a long description for an encoding name.

Parameters
encodingthe encoding for the language
Returns
the long description for the encoding

Definition at line 378 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 407 of file kcharsets.cpp.

◆ encodingForName()

QString KCharsets::encodingForName ( const QString & descriptiveName) const

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

Parameters
descriptiveNamethe descriptive name for the encoding
Returns
the name of the encoding

Definition at line 388 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 419 of file kcharsets.cpp.

◆ fromEntity() [1/2]

QChar KCharsets::fromEntity ( QStringView str)
static

Converts an entity to a character.

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

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

Definition at line 252 of file kcharsets.cpp.

◆ fromEntity() [2/2]

QChar KCharsets::fromEntity ( QStringView str,
int & len )
static

Overloaded member function.

Tries to find an entity in the QString str.

Parameters
strthe string containing entified
lenis 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 298 of file kcharsets.cpp.

◆ resolveEntities()

QString KCharsets::resolveEntities ( const QString & text)
static

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

Parameters
textthe string containing the entities
Returns
the clean string

Definition at line 319 of file kcharsets.cpp.

◆ toEntity()

QString KCharsets::toEntity ( const QChar & ch)
static

Converts a QChar to an entity.

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

Parameters
chthe char to convert
Returns
the entity

Definition at line 314 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-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:51:54 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.