|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This file contains the API definition for escape enoding functionality |
|
15 // and UNICODE/UTF8 conversion. Escape encoding is performed as specified |
|
16 // by RFC2396. |
|
17 // |
|
18 // |
|
19 |
|
20 /** |
|
21 @file EscapeUtils.h |
|
22 @publishedAll |
|
23 @released |
|
24 */ |
|
25 |
|
26 #ifndef __ESCAPEUTILS_H__ |
|
27 #define __ESCAPEUTILS_H__ |
|
28 |
|
29 // System includes |
|
30 // |
|
31 #include <e32base.h> |
|
32 #include <uriutilscommon.h> |
|
33 |
|
34 |
|
35 /** |
|
36 Comments : Provides an API to allow data to be escape encoded and decoded. |
|
37 Also provide an API for converting a UNICODE data (16-bit descriptor) into |
|
38 UTF8 data (8-bit descriptor) and vice-verse. |
|
39 @publishedAll |
|
40 @released |
|
41 @since 6.0 |
|
42 */ |
|
43 class EscapeUtils |
|
44 { |
|
45 public: // Enums |
|
46 |
|
47 /** |
|
48 enum TEscapeMode |
|
49 Enum defining escaping modes. Each mode has a different set of reserved characters. |
|
50 These are based on various uri components, as decribed in RFC2396. |
|
51 */ |
|
52 enum TEscapeMode |
|
53 { |
|
54 /** Default mode, which has no reserved characters */ |
|
55 EEscapeNormal = 0, |
|
56 /** Mode specifying reserved characters in a uri query - ;/?:@&=+$,[] */ |
|
57 EEscapeQuery, |
|
58 /** Mode specifying reserved characters in a uri path - /;=?[] */ |
|
59 EEscapePath, |
|
60 /** Mode specifying reserved characters in a uri authority - /;:@?[] */ |
|
61 EEscapeAuth, |
|
62 /** Mode specifying reserved characters in a URL ;/?:@&=+$[]!\'()~ */ |
|
63 EEscapeUrlEncoded |
|
64 }; |
|
65 |
|
66 public: // Methods |
|
67 |
|
68 IMPORT_C static HBufC8* EscapeEncodeL(const TDesC8& aData, TEscapeMode aMode); |
|
69 |
|
70 IMPORT_C static HBufC16* EscapeEncodeL(const TDesC16& aData, TEscapeMode aMode); |
|
71 |
|
72 IMPORT_C static HBufC8* EscapeEncodeL(const TDesC8& aData, const TDesC8& aReservedChars); |
|
73 |
|
74 IMPORT_C static HBufC16* EscapeEncodeL(const TDesC16& aData, const TDesC16& aReservedChars); |
|
75 |
|
76 IMPORT_C static HBufC8* EscapeDecodeL(const TDesC8& aData); |
|
77 |
|
78 IMPORT_C static HBufC16* EscapeDecodeL(const TDesC16& aData); |
|
79 |
|
80 IMPORT_C static HBufC8* ConvertFromUnicodeToUtf8L(const TDesC& aData); |
|
81 |
|
82 IMPORT_C static HBufC* ConvertToUnicodeFromUtf8L(const TDesC8& aData); |
|
83 |
|
84 IMPORT_C static TBool IsExcludedChar(TChar aChar); |
|
85 |
|
86 IMPORT_C static TBool IsEscapeTriple(const TDesC8& aData, TInt& aHexValue); |
|
87 |
|
88 IMPORT_C static TBool IsEscapeTriple(const TDesC16& aData, TInt& aHexValue); |
|
89 |
|
90 IMPORT_C static HBufC8* SpecificEscapeEncodeL ( const TDesC8& aData, const TDesC8& aCharsToEscape ); |
|
91 |
|
92 static HBufC8* ReEscapeEncodeL(const TDesC8& aData); |
|
93 |
|
94 private: // Dummy Method |
|
95 |
|
96 IMPORT_C static HBufC8* DummyForwardingFunctionForCompatibility( const TDesC8& aData, const TDesC8& aCharsToEscape ); |
|
97 |
|
98 }; |
|
99 |
|
100 #endif // __ESCAPEUTILS_H__ |