|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE task |
|
11 PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"> |
|
12 <task id="GUID-2068DA42-AE77-5213-B3CF-C3AB7F2188BE" xml:lang="en"><title>Using |
|
13 a FAT Filename Conversion Plug-in</title><shortdesc>This section describes how to dynamically load and call a FAT Filename |
|
14 Conversion plug-in to convert file names between Unicode and Windows code |
|
15 page. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody> |
|
16 <prereq><p>This tutorial assumes that you have an understanding of the following: </p> <ul> |
|
17 <li id="GUID-DB5761AA-9988-5D61-B42B-9DA5AF0B154B"><p><xref href="GUID-66231EA2-BDEF-582D-A4B9-F356B590038D.dita">FAT |
|
18 Filename Conversion Plug-ins Overview</xref> introduces Windows code page |
|
19 and the main purpose of the Plug-ins component. </p> </li> |
|
20 </ul> </prereq> |
|
21 <steps id="GUID-FA2D288A-1D18-504A-86EA-C89876400630"> |
|
22 <step id="GUID-3706C5D9-0767-528C-A071-7597C8EE8780"><cmd>Load |
|
23 the FAT Filename Conversion plug-in DLL. </cmd> |
|
24 <stepxmp><codeblock id="GUID-996C058A-7F99-5B20-A6D3-027DB9722421" xml:space="preserve">_LIT(KName,"cp1250"); //The name of the plug-in DLL |
|
25 const TUid KPluginUid={0x10206A9C}; //DLL UID acquired from Symbian |
|
26 RLibrary lib; |
|
27 |
|
28 //Encapsulate the UID of this DLL in TUidType. |
|
29 const TUidType serverUid(KNullUid,KNullUid,KPluginUid); |
|
30 |
|
31 //load the DLL |
|
32 User::LeaveIfError(lib.Load(KName,serverUid));</codeblock> </stepxmp> |
|
33 <info><p>In this example, <filepath>cp1250.dll</filepath> is dynamically loaded. |
|
34 A function is then called to convert a character from Unicode to CP1250. </p></info> |
|
35 </step> |
|
36 <step id="GUID-3DB9A9F0-244D-5037-82DA-458C89EF80F2"><cmd/> |
|
37 <info>Get the exported function from the DLL. </info> |
|
38 <stepxmp><codeblock id="GUID-F85F30A1-C528-5299-AC35-E698CB350771" xml:space="preserve">// Function at ordinal 1 converts text from a Unicode to CP1250. |
|
39 TLibraryFunction function1 = lib.Lookup(1); |
|
40 |
|
41 typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&); |
|
42 TConvertFromUnicodeL aConvertFromUnicodeL = |
|
43 reinterpret_cast <TConvertFromUnicodeL> (function1);</codeblock> </stepxmp> |
|
44 </step> |
|
45 <step id="GUID-CD49317B-9C3D-565C-B31E-0471109FA1A7"><cmd/> |
|
46 <info>Call the function to convert the text from Unicode to CP1250. </info> |
|
47 <stepxmp><codeblock id="GUID-2259D92B-5BAA-503D-9E80-6B19A38B8877" xml:space="preserve">TBuf8<15> foreign1; |
|
48 _LIT16(Uni_1, "\x0053\x0059\x004D\x0042\x0049\x0041\x004E\xFFFD\x20AC\x02C7\x2015"); |
|
49 const TDesC16& unicode1(Uni_1); |
|
50 (*aConvertFromUnicodeL)(foreign1, unicode1); |
|
51 ...</codeblock> </stepxmp> |
|
52 </step> |
|
53 <step id="GUID-7E911758-4430-5507-829F-6096564611F2"><cmd/> |
|
54 <info>Close the DLL. </info> |
|
55 <stepxmp><codeblock id="GUID-59C882FD-A92F-518C-B69D-F1C0FB151B3A" xml:space="preserve">lib.Close();</codeblock> </stepxmp> |
|
56 </step> |
|
57 </steps> |
|
58 <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> |
|
59 </taskbody><related-links> |
|
60 <link href="GUID-026E865E-12FA-59A9-B923-309B65790E23.dita"><linktext>Creating |
|
61 a FAT Filename Conversion Plug-in</linktext></link> |
|
62 </related-links></task> |