org.kde.koala
Class KCharsets

java.lang.Object
  extended by org.kde.koala.KCharsets
All Implemented Interfaces:
org.kde.qt.QtSupport

public class KCharsets
extends java.lang.Object
implements org.kde.qt.QtSupport

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

Constructor Summary
  KCharsets()
          Protected constructor.
protected KCharsets(java.lang.Class dummy)
           
 
Method Summary
 java.util.ArrayList availableEncodingNames()
          Lists all available encodings as names.
 org.kde.qt.QTextCodec codecForName(java.lang.String name)
          Provided for compatibility.
 org.kde.qt.QTextCodec codecForName(java.lang.String n, boolean ok)
          Tries to find a QTextCodec to convert the given encoding from and to Unicode.
 java.util.ArrayList descriptiveEncodingNames()
          Lists the available encoding names together with a more descriptive language.
 void dispose()
          Delete the wrapped C++ instance ahead of finalize()
 java.lang.String encodingForName(java.lang.String descriptiveName)
          Returns the encoding for a string obtained with descriptiveEncodingNames().
protected  void finalize()
          Deletes the wrapped C++ instance
static char fromEntity(java.lang.String str)
          Converts an entity to a character.
static char fromEntity(java.lang.String str, int[] len)
          Overloaded member function.
 boolean isDisposed()
          Has the wrapped C++ instance been deleted?
 java.lang.String languageForEncoding(java.lang.String encoding)
          Returns the language the encoding is used for.
static java.lang.String resolveEntities(java.lang.String text)
          Scans the given string for entities (like &) and resolves them using fromEntity.
static java.lang.String toEntity(char ch)
          Converts a char to an entity.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KCharsets

protected KCharsets(java.lang.Class dummy)

KCharsets

public KCharsets()
Protected constructor. If you need the kcharsets object, use KGlobal.charsets() instead.

Method Detail

codecForName

public org.kde.qt.QTextCodec codecForName(java.lang.String name)
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

codecForName

public org.kde.qt.QTextCodec codecForName(java.lang.String n,
                                          boolean ok)
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

availableEncodingNames

public java.util.ArrayList availableEncodingNames()
Lists all available encodings as names.

Returns:
the list of all encodings

descriptiveEncodingNames

public java.util.ArrayList descriptiveEncodingNames()
Lists the available encoding names together with a more descriptive language.

Returns:
the list of descriptive encoding names

languageForEncoding

public java.lang.String languageForEncoding(java.lang.String encoding)
Returns the language the encoding is used for.

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

encodingForName

public java.lang.String encodingForName(java.lang.String descriptiveName)
Returns the encoding for a string obtained with descriptiveEncodingNames().

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

fromEntity

public static char fromEntity(java.lang.String str)
Converts an entity to a character. The string must contain only the entity without the trailing ';'.

Parameters:
str - the entity
Returns:
char.null if the entity could not be decoded.

fromEntity

public static char fromEntity(java.lang.String str,
                              int[] len)
Overloaded member function. Tries to find an entity in the String 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, char.null otherwise

toEntity

public static java.lang.String toEntity(char ch)
Converts a char to an entity. The returned string does already contain the leading '&' and the trailing ';'.

Parameters:
ch - the char to convert
Returns:
the entity

resolveEntities

public static java.lang.String resolveEntities(java.lang.String text)
Scans the given string for entities (like &) and resolves them using fromEntity.

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

finalize

protected void finalize()
                 throws java.lang.InternalError
Deletes the wrapped C++ instance

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.InternalError

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()


isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?