|
1 // Copyright (c) 1997-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 // Implement case-insensitive comparison using the full folded comparison |
|
15 // functions of E32 |
|
16 // |
|
17 // |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <string.h> |
|
21 |
|
22 /** |
|
23 Compares the null-terminated strings left and right and returns an integer |
|
24 greater than,equal to, or less than zero (0), accordingly as left |
|
25 is lexicographically greater than,equal to, or less than right after |
|
26 translation of each corresponding character to lowercase. |
|
27 @return an integer greater than, equal to, or less than zero (0), |
|
28 accordingly as the string left is greater than, equal to, |
|
29 or less than the string right. |
|
30 @param left The first string to compare. |
|
31 @param right The second string to compare. |
|
32 */ |
|
33 extern "C" EXPORT_C int strcasecmp (const char *left, const char *right) |
|
34 { |
|
35 TPtrC8 Left((const TText8*)left); |
|
36 TPtrC8 Right((const TText8*)right); |
|
37 return Left.CompareF(Right); |
|
38 } |
|
39 |
|
40 extern "C" EXPORT_C int strncasecmp (const char *left, const char *right, size_t length) |
|
41 { |
|
42 TUint leftlength=strlen(left); |
|
43 TUint rightlength=strlen(right); |
|
44 // The length parameter is the maximum amount of the string to be searched, |
|
45 // so truncate the descriptors appropriately |
|
46 if (leftlength>length) |
|
47 leftlength=length; |
|
48 if (rightlength>length) |
|
49 rightlength=length; |
|
50 TPtrC8 Left((const TText8*)left,leftlength); |
|
51 TPtrC8 Right((const TText8*)right,rightlength); |
|
52 return Left.CompareF(Right); |
|
53 } |