Using a FAT Filename Conversion Plug-in

This section describes how to dynamically load and call a FAT Filename Conversion plug-in to convert file names between Unicode and Windows code page.

Prerequisites

This tutorial assumes that you have an understanding of the following:

Steps

  1. Load the FAT Filename Conversion plug-in DLL.

    _LIT(KName,"cp1250");  //The name of the plug-in DLL
    const TUid KPluginUid={0x10206A9C}; //DLL UID acquired from Symbian
    RLibrary lib;
    
    //Encapsulate the UID of this DLL in TUidType.
    const TUidType serverUid(KNullUid,KNullUid,KPluginUid);    
    
    //load the DLL
    User::LeaveIfError(lib.Load(KName,serverUid));

    In this example, cp1250.dll is dynamically loaded. A function is then called to convert a character from Unicode to CP1250.

  2. Get the exported function from the DLL.
    // Function at ordinal 1 converts text from a Unicode to CP1250.
    TLibraryFunction function1 = lib.Lookup(1);
    
    typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);    
    TConvertFromUnicodeL aConvertFromUnicodeL = 
                                reinterpret_cast <TConvertFromUnicodeL> (function1);
  3. Call the function to convert the text from Unicode to CP1250.
    TBuf8<15> foreign1;
    _LIT16(Uni_1, "\x0053\x0059\x004D\x0042\x0049\x0041\x004E\xFFFD\x20AC\x02C7\x2015");
    const TDesC16& unicode1(Uni_1);
    (*aConvertFromUnicodeL)(foreign1, unicode1);
    ...
  4. Close the DLL.
    lib.Close();

Results

The parameter foreign1 is returned with the value "\0x53\0x59\0x4D\0x42\0x49\0x41\0x4E\0x81\0x80\0xA1\0x5F" which is in the CP1250 encoding.

Related tasks