|
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 concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-38B65AAC-3CFA-5C9B-AD6F-36823B6C2C0E" xml:lang="en"><title>Escape |
|
13 and Insert</title><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <p>This section explains the concept of escape and insert, which is necessary |
|
15 for avoiding conflicts of characters and interpreting URI correctly. </p> |
|
16 <p>A character in the URI may not be available on the keyboard or might not |
|
17 be usable in contexts where it may conflict with a reserved character. In |
|
18 either case, the character can be encoded with a '<i>%</i>' followed by its |
|
19 ASCII hexadecimal equivalent code. For more information, refer to <xref href="GUID-0E8206E9-4F1D-5DF5-8A69-9B0831061CFF.dita">Escape |
|
20 encoding and decoding</xref>. </p> |
|
21 <p>The following example shows how the character "#" is encoded with a "%" |
|
22 followed by its ASCII hexadecimal equivalent code "%23". To modify the data |
|
23 and escape encode, the following functions are used: </p> |
|
24 <codeblock id="GUID-46E2E0B1-28D3-5F96-8C34-3447C8A1B2D3" xml:space="preserve">_LIT8(KInsertEscape,"file#1"); //data to insert |
|
25 dpath->InsertAndEscapeCurrentL(KInsertEscape); //escape encode and insert segment |
|
26 const TDesC8& des = dpath->Parser().Des(); //descritpor contains "/Myfolder/file%231/logs"</codeblock> |
|
27 <p>The code escape encodes the segment and inserts the escaped version before |
|
28 the current parsed segment. <codeph>des</codeph> holds "<codeph>/Myfolder/file%231/logs</codeph> " |
|
29 after inserting the escape encoded segment "<codeph>file%231</codeph> ". </p> |
|
30 <codeblock id="GUID-50E07325-077F-52FE-BD56-FB649FE16BF4" xml:space="preserve">_LIT8(KPushEscape,"file#1"); |
|
31 dpath->PushAndEscapeFrontL(KPushEscape); //escape encode and insert the segment |
|
32 const TDesC8& des6 = dpath->Parser().Des(); //descritpor contains "/file%231/Myfolder/logs"</codeblock> |
|
33 <p> <xref href="GUID-6BD89347-671F-3518-9777-55801A090C79.dita"><apiname/></xref> The code escape encodes the segment <codeph>file#1</codeph> and |
|
34 inserts the escaped version at the beginning of the path. <codeph>des</codeph> holds |
|
35 "<codeph>/file%231/Myfolder/logs</codeph> " after inserting "<codeph>file%231</codeph> ". |
|
36 To insert an escape encoded version of the segment at the end of the path, |
|
37 use <xref href="GUID-51DFAA06-EC5E-32E6-9819-39938C46B2C0.dita#GUID-51DFAA06-EC5E-32E6-9819-39938C46B2C0/GUID-8B544BA8-C70B-3BF1-A752-6424CA9B28EB"><apiname>CDelimitedPath8::PushAndEscapeFrontL()</apiname></xref>. </p> |
|
38 <p>In all the three insert functions, the newly inserted segments should contain |
|
39 a single path segment, as any path delimiters in the segment will be converted |
|
40 to an escape triple. </p> |
|
41 <p> <b> Note</b>: In case of Unicode data, first convert to utf8, escape encode, |
|
42 re-convert to 16-bit, and then insert the escaped version of the path segment. </p> |
|
43 </conbody><related-links> |
|
44 <link href="GUID-795B41AF-FBEA-56CE-AE20-EF17BE754723.dita"><linktext>HTTP Utilities |
|
45 Library Overview</linktext></link> |
|
46 <link href="GUID-42F0F282-58D6-4878-B53D-EAEEF86A3D7D.dita"><linktext>Parsing |
|
47 Delimited Data</linktext></link> |
|
48 <link href="GUID-834F5FC8-EBE4-4076-B1E3-38DDFF89D700.dita"><linktext>Modifying |
|
49 the Data and Delimiter</linktext></link> |
|
50 </related-links></concept> |