|
1 /* |
|
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Note: This file may contain code to generate corrupt files for test purposes. |
|
16 * Such code is excluded from production builds by use of compiler defines; |
|
17 * it is recommended that such code should be removed if this code is ever published publicly. |
|
18 * various utility functions |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 /** |
|
24 @file |
|
25 @internalComponent |
|
26 @released |
|
27 */ |
|
28 |
|
29 #ifndef __UTILS_H_ |
|
30 #define __UTILS_H_ |
|
31 |
|
32 // =========================================================================== |
|
33 // INCLUDES |
|
34 // =========================================================================== |
|
35 |
|
36 #include "utility_interface.h" |
|
37 #include <wchar.h> |
|
38 #include "basetype.h" |
|
39 #include <iostream> |
|
40 |
|
41 |
|
42 enum TUtilsException |
|
43 {ErrNotEnoughMemory =-1, |
|
44 ErrCannotOpenFile =-2, |
|
45 ErrCannotReadFile =-3, |
|
46 ErrCannotWriteFile =-4, |
|
47 ErrCannotConvertFile=-5, |
|
48 ErrCertFileKeyFileMismatch = -6}; |
|
49 |
|
50 enum TEncodingScheme |
|
51 { |
|
52 EAscii = 0, |
|
53 EUtf8 = 1, |
|
54 EUcs2LE = 2, |
|
55 EUcs2BE = 3, |
|
56 }; |
|
57 |
|
58 // =========================================================================== |
|
59 // GLOBAL FUNCTIONS |
|
60 // =========================================================================== |
|
61 |
|
62 // is a file unicode |
|
63 bool FileIsUnicode(LPCWSTR fileName, TEncodingScheme& encScheme); |
|
64 // create a temporary file which is a UCS2 little endian UNICODE version of a |
|
65 // big endian UNICODE file |
|
66 LPWSTR ConvertUCS2FileToLittleEndianUnicode(LPCWSTR fileName); |
|
67 // create a temporary file which is a UCS4 little endian UNICODE version of a |
|
68 // big endian UNICODE file |
|
69 LPWSTR ConvertUCS4FileToLittleEndianUnicode(LPCWSTR fileName); |
|
70 // create a temporary file which is a UNICODE version of an MBCS file |
|
71 LPWSTR ConvertFileToUnicode(LPCWSTR fileName, TEncodingScheme encScheme); |
|
72 // get a temporary filename (in c:\temp\mks???\ with given file name) |
|
73 LPWSTR TempFileName(); |
|
74 // Verifies if given buffer has correct UTF8 encoding |
|
75 bool CorrectUTF8(LPSTR pNarrowBuf, DWORD dwNumBytes); |
|
76 // Convert UCS2 file to UCS4 format |
|
77 LPWSTR ConvertUCS2FileToUCS4(LPCWSTR fileName); |
|
78 |
|
79 #endif |