• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

KCharsets Class Reference

Charset font and encoder/decoder handling. More...

#include <kcharsets.h>

List of all members.

Public Member Functions

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
KDE_DEPRECATED QString languageForEncoding (const QString &encoding) const
virtual ~KCharsets ()

Static Public Member Functions

static QChar fromEntity (const QString &str, int &len)
static QChar fromEntity (const QString &str)
static QString resolveEntities (const QString &text)
static QString toEntity (const QChar &ch)

Protected Member Functions

 KCharsets ()

Friends

KCharsets * KGlobal::charsets ()

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 (  )  [protected]

Protected constructor.

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

Definition at line 512 of file kcharsets.cpp.

KCharsets::~KCharsets (  )  [virtual]

Destructor.

Definition at line 517 of file kcharsets.cpp.


Member Function Documentation

QStringList KCharsets::availableEncodingNames (  )  const

Lists all available encodings as names.

Returns:
the list of all encodings

Definition at line 634 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.

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

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

Definition at line 720 of file kcharsets.cpp.

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

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

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

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

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

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

QChar KCharsets::fromEntity ( const QString &  str,
int &  len 
) [static]

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

QChar KCharsets::fromEntity ( const QString &  str  )  [static]

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

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

Returns the language the encoding is used for.

Parameters:
encoding the 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 643 of file kcharsets.cpp.

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

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

Parameters:
text the string containing the entities
Returns:
the clean string

Definition at line 588 of file kcharsets.cpp.

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:
ch the char to convert
Returns:
the entity

Definition at line 581 of file kcharsets.cpp.


Friends And Related Function Documentation

KCharsets* KGlobal::charsets (  )  [friend]

The documentation for this class was generated from the following files:
  • kcharsets.h
  • kcharsets.cpp

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal