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:
Call CConverterBase2::ConvertAL() (files) or CConverterBase2::ConvertObjectAL() (streams) to prepare the converter to convert.
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.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.