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

KDECore

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
KCharsets Class Reference

#include <kcharsets.h>

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
 
QString languageForEncoding (const QString &encoding) const
 

Static Public Member Functions

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 46 of file kcharsets.h.

Constructor & Destructor Documentation

◆ KCharsets()

KCharsets::KCharsets ( )
protected

Protected constructor.

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

Definition at line 486 of file kcharsets.cpp.

◆ ~KCharsets()

KCharsets::~KCharsets ( )
virtual

Destructor.

Definition at line 491 of file kcharsets.cpp.

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.

◆ 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.

Parameters
nthe name of the codec
oktrue 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 708 of file kcharsets.cpp.

◆ codecForName() [2/2]

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

Provided for compatibility.

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

Definition at line 696 of file kcharsets.cpp.

◆ descriptionForEncoding()

QString KCharsets::descriptionForEncoding ( const QString & 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 630 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 659 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 642 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 672 of file kcharsets.cpp.

◆ fromEntity() [1/2]

QChar KCharsets::fromEntity ( const QString & 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 496 of file kcharsets.cpp.

◆ fromEntity() [2/2]

QChar KCharsets::fromEntity ( const QString & 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 539 of file kcharsets.cpp.

◆ languageForEncoding()

QString KCharsets::languageForEncoding ( const QString & encoding) const

Returns the language the encoding is used for.

Parameters
encodingthe encoding for the language
Returns
the language of the encoding
Deprecated
Please use descriptionForEncoding instead. This function will be removed before KDE4 is released.

Definition at line 618 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 562 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 555 of file kcharsets.cpp.


The documentation for this class was generated from the following files:
  • kcharsets.h
  • kcharsets.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Thu Jul 18 2024 00:00:00 by doxygen 1.11.0 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
  • 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