kdecore Library API Documentation

KCharsets Class Reference

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

#include <kcharsets.h>

List of all members.

Public Methods

virtual ~KCharsets ()
 Destructor.

QTextCodeccodecForName (const QString &name) const
 Provided for compatibility.

QTextCodeccodecForName (const QString &n, bool &ok) const
 Tries to find a QTextCodec to convert the given encoding from and to Unicode.

QStringList availableEncodingNames ()
 Lists all available encodings as names.

QStringList descriptiveEncodingNames ()
 Lists the available encoding names together with a more descriptive language.

QStringList languages ()
 Lists all languages.

QStringList encodingsForLanguage (const QString &language)
 Lists all available encodings for language name 'language'.

QString languageForEncoding (const QString &encoding)
 Returns the language the encoding is used for.

QString encodingForName (const QString &descriptiveName)
 Returns the encoding for a string obtained with descriptiveEncodingNames().


Static Public Methods

QChar fromEntity (const QString &str)
 Converts an entity to a character.

QChar fromEntity (const QString &str, int &len)
 Overloaded member function.

QString toEntity (const QChar &ch)
 Converts a QChar to an entity.

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


Protected Methods

 KCharsets ()
 Protected constructor.


Detailed Description

Charset font and encoder/decoder handling.

This is needed, because Qt's font matching algorithm gives the font family a higher priority than the charset. For many applications this is not acceptable, since it can totally obscure the output, in languages which use non iso-8859-1 charsets.

Author:
Lars Knoll <knoll@kde.org>
Version:
Id:
kcharsets.h,v 1.53 2002/09/28 11:14:45 tjansen Exp

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

KCharsets::~KCharsets   [virtual]
 

Destructor.

Definition at line 350 of file kcharsets.cpp.


Member Function Documentation

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 (Latin-1) codec

Definition at line 516 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 latin1 codec will be returned an ok will be set to false.

Returns:
the QTextCodec. If the desired codec could not be found, it returns a default (Latin-1) codec

Definition at line 522 of file kcharsets.cpp.

References KLocale::codecForEncoding(), QTextCodec::codecForName(), KGlobal::config(), QString::fromLatin1(), QCString::isEmpty(), QString::isEmpty(), KStdAccel::key(), QString::latin1(), QCString::length(), QTextCodec::loadCharmapFile(), KGlobal::locale(), QCString::lower(), QString::lower(), KConfigBase::readEntry(), QCString::right(), QCString::truncate(), and QCString::upper().

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

References QString::ascii(), QString::length(), QString::toInt(), and QString::unicode().

Referenced by fromEntity(), and resolveEntities().

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

References fromEntity(), and QString::left().

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

References QString::sprintf(), and QChar::unicode().

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
Since:
3.1

Definition at line 414 of file kcharsets.cpp.

References KStdAccel::end(), fromEntity(), QChar::isNull(), QString::length(), QString::remove(), and QString::unicode().

QStringList KCharsets::availableEncodingNames  
 

Lists all available encodings as names.

Returns:
the list of all encodings

Definition at line 460 of file kcharsets.cpp.

References QString::fromLatin1().

Referenced by descriptiveEncodingNames().

QStringList KCharsets::descriptiveEncodingNames  
 

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

Returns:
the list of descriptive encoding names

Definition at line 504 of file kcharsets.cpp.

References availableEncodingNames(), KGlobal::charsets(), languageForEncoding(), and QStringList::sort().

QStringList KCharsets::languages  
 

Lists all languages.

Returns:
a list of all languages

QStringList KCharsets::encodingsForLanguage const QString   language
 

Lists all available encodings for language name 'language'.

Parameters:
language  to language to search for
Returns:
the list of encodings for the language

QString KCharsets::languageForEncoding const QString   encoding
 

Returns the language the encoding is used for.

Parameters:
encoding  the encoding for the language
Returns:
the language of the encoding

Definition at line 490 of file kcharsets.cpp.

References QString::latin1().

Referenced by descriptiveEncodingNames().

QString KCharsets::encodingForName const QString   descriptiveName
 

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

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

Definition at line 497 of file kcharsets.cpp.

References QString::find(), and QString::mid().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:20:44 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001