Request for conversions

Conversions can be done in a single step or in multiple steps.

Single step

To convert an entire file or stream in a single step, use CConverterBase2::ConvertL() and CConverterBase2::ConvertObjectL() respectively.

The following code snippet converts the contents of c:\private\12345678\file1 and places the output in c:\private\12345678\file2.

_LIT(KFromFile, "c:\\private\\12345678\\file1");
_LIT(KToFile, "c:\\private\\12345678\\file2");
converter->ConvertL(KFromFile, KToFile, NULL);

Multiple steps

As the conversion process can take a long time, you can divide the process into multiple steps. To do this:

  1. Call CConverterBase2::ConvertAL() (files) or CConverterBase2::ConvertObjectAL() (streams) to prepare the converter to convert.

  2. Call CConverterBase2::DoConvertL() until it returns true.

The following example converts the contents of c:\private\12345678\file1 and places the output in c:\private\12345678\file2 in multiple steps. It assumes that conversion takes place within an active object, CMyActive, which does a conversion step in the RunL() function and reactivates the object if conversion is not complete.

void CMyActive::StartConverting()
    {
    _LIT( KFromFile, "c:\\private\\12345678\\file1" );
    _LIT( KToFile, "c:\\private\\12345678\\file2" );
    converter->ConvertAL( KFromFile, KToFile, NULL );
    User::RequestComplete( iStatus,KErrNone );
    SetActive();
    }
void CMyActive::RunL()
    {
    if (DoConvertL())
        {
        User::RequestComplete( iStatus,KErrNone );
        SetActive();
        }
    else
        {
        // Handle completed conversion
        }
    }

NOTE: After using the converter, delete the converter and the converter list. The converter architecture unloads the converter DLLs that were loaded.