Qt API | Qtopia API | Qtopia Documentation |

# TextCodecInterface Class Reference

The TextCodecInterface class defines the interface for text codec plugins. More...

`#include <qtopia/textcodecinterface.h>`

List of all member functions.

## Public Members

- virtual QStringList names () const = 0
- virtual QTextCodec * createForName ( const QString & name ) = 0
- virtual QValueList<int> mibEnums () const = 0
- virtual QTextCodec * createForMib ( int mib ) = 0

## Detailed Description

The TextCodecInterface class defines the interface for text codec plugins.

Internally, Qtopia works completely with Unicode text strings, however it is sometimes necessary to convert to or from other character sets.

To add support for a character set format, you must create a Text Codec plugin. To do so, follow these steps:

1. Create a subclass of QTextCodec that implements the conversion. This procedure is a standard part of Qt, and is documented there.
2. Create a subclass of TextCodecInterface that creates your QTextCodec subclass. Ensure that your class:
   - Inherits TextCodecInterface
   - Inplements all pure-virtual methods of TextCodecInterface
   - Includes the declarations:

         public:
             QRESULT queryInterface( const QUuid&, QUnknownInterface** );
             Q_REFCOUNT
         private:
             ulong ref;

3. In the code of the TextCodecInterface subclass:

       QRESULT YourTextCodecInterfaceSubClass::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
       {
           *iface = 0;
           if ( uuid == IID_QUnknown )
               *iface = this;
           else if ( uuid == IID_QtopiaTextCodec )
               *iface = this;

           if ( *iface )
               (*iface)->addRef();
           return (*iface) ? QS_OK : QS_FALSE;
       }

       Q_EXPORT_INTERFACE()
       {
           Q_CREATE_INSTANCE( YourTextCodecInterfaceSubClass )
       }

4. Build your code as a Shared Object (.so file) (such as by using the tmake lib template).
5. Ship your plugin in the Qtopia plugins/textcodecs/ directory.

## Member Function Documentation

### QTextCodec * TextCodecInterface::createForMib ( int mib )`[pure virtual]`

Returns a new QTextCodec (subclass) for the given mib.

### QTextCodec * TextCodecInterface::createForName ( const QString & name )`[pure virtual]`

Returns a new QTextCodec (subclass) for the given codec name.

### QValueList<int> TextCodecInterface::mibEnums () const`[pure virtual]`

Returns the list of codec MIBs. You should use IANA registered MIB values.

### QStringList TextCodecInterface::names () const`[pure virtual]`

Returns the list of codec names. You should use IANA registered names.

This file is part of the Qtopia , copyright © 1995-2002 Trolltech, all rights reserved.