Symbian3/SDK/Source/GUID-2068DA42-AE77-5213-B3CF-C3AB7F2188BE.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE task
  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-2068DA42-AE77-5213-B3CF-C3AB7F2188BE" xml:lang="en"><title>Using
a FAT Filename Conversion Plug-in</title><shortdesc>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. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
<prereq><p>This tutorial assumes that you have an understanding of the following: </p> <ul>
<li id="GUID-DB5761AA-9988-5D61-B42B-9DA5AF0B154B"><p><xref href="GUID-66231EA2-BDEF-582D-A4B9-F356B590038D.dita">FAT
Filename Conversion Plug-ins Overview</xref> introduces Windows code page
and the main purpose of the Plug-ins component. </p> </li>
</ul> </prereq>
<steps id="GUID-FA2D288A-1D18-504A-86EA-C89876400630">
<step id="GUID-3706C5D9-0767-528C-A071-7597C8EE8780"><cmd>Load
the FAT Filename Conversion plug-in DLL. </cmd>
<stepxmp><codeblock id="GUID-996C058A-7F99-5B20-A6D3-027DB9722421" xml:space="preserve">_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));</codeblock> </stepxmp>
<info><p>In this example, <filepath>cp1250.dll</filepath> is dynamically loaded.
A function is then called to convert a character from Unicode to CP1250.  </p></info>
</step>
<step id="GUID-3DB9A9F0-244D-5037-82DA-458C89EF80F2"><cmd/>
<info>Get the exported function from the DLL. </info>
<stepxmp><codeblock id="GUID-F85F30A1-C528-5299-AC35-E698CB350771" xml:space="preserve">// Function at ordinal 1 converts text from a Unicode to CP1250.
TLibraryFunction function1 = lib.Lookup(1);

typedef void (*TConvertFromUnicodeL)(TDes8&amp;, const TDesC16&amp;);    
TConvertFromUnicodeL aConvertFromUnicodeL = 
                            reinterpret_cast &lt;TConvertFromUnicodeL&gt; (function1);</codeblock> </stepxmp>
</step>
<step id="GUID-CD49317B-9C3D-565C-B31E-0471109FA1A7"><cmd/>
<info>Call the function to convert the text from Unicode to CP1250. </info>
<stepxmp><codeblock id="GUID-2259D92B-5BAA-503D-9E80-6B19A38B8877" xml:space="preserve">TBuf8&lt;15&gt; foreign1;
_LIT16(Uni_1, "\x0053\x0059\x004D\x0042\x0049\x0041\x004E\xFFFD\x20AC\x02C7\x2015");
const TDesC16&amp; unicode1(Uni_1);
(*aConvertFromUnicodeL)(foreign1, unicode1);
...</codeblock> </stepxmp>
</step>
<step id="GUID-7E911758-4430-5507-829F-6096564611F2"><cmd/>
<info>Close the DLL. </info>
<stepxmp><codeblock id="GUID-59C882FD-A92F-518C-B69D-F1C0FB151B3A" xml:space="preserve">lib.Close();</codeblock> </stepxmp>
</step>
</steps>
<result><p>The parameter <codeph>foreign1</codeph> is returned with the value <codeph>"\0x53\0x59\0x4D\0x42\0x49\0x41\0x4E\0x81\0x80\0xA1\0x5F"</codeph> which is in the CP1250 encoding. </p> </result>
</taskbody><related-links>
<link href="GUID-026E865E-12FA-59A9-B923-309B65790E23.dita"><linktext>Creating
a FAT Filename Conversion                 Plug-in</linktext></link>
</related-links></task>