|
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 // Use E32 function equivalent of ctype.h macros. |
|
15 // This is hideously expensive, involving EXEC calls to read the array, |
|
16 // but we do get proper localisation. |
|
17 // |
|
18 // |
|
19 |
|
20 #include <e32std.h> |
|
21 #include <_ansi.h> |
|
22 #include <ctype.h> |
|
23 |
|
24 extern "C" { |
|
25 |
|
26 |
|
27 /** |
|
28 Tests whether the character is alphabetic or a decimal digit. |
|
29 @return non-zero for true and zero for false. If the parameter is not in the domain |
|
30 of the function, the return result is undefined. |
|
31 @param c an integer whose value is representable as an unsigned char. |
|
32 */ |
|
33 EXPORT_C int isalnum(int c) |
|
34 { |
|
35 return TChar((TUint)c).IsAlphaDigit(); |
|
36 } |
|
37 |
|
38 /** |
|
39 Test for an alphabetic character. |
|
40 For Unicode, the function returns TRUE for all letters, including those from |
|
41 syllabaries and ideographic scripts. The function returns FALSE for |
|
42 letter-like characters that are in fact diacritics. |
|
43 Specifically, the function returns TRUE for categories: |
|
44 ELuCategory, ELtCategory, ELlCategory, and ELoCategory; |
|
45 it returns FALSE for all other categories including ELmCategory. |
|
46 @return True, if the character is alphabetic; false, otherwise. |
|
47 @param c an integer whose value is representable as an unsigned char. |
|
48 */ |
|
49 EXPORT_C int isalpha(int c) |
|
50 { |
|
51 return TChar((TUint)c).IsAlpha(); |
|
52 } |
|
53 |
|
54 /** |
|
55 Tests whether the character is a control character. |
|
56 For Unicode, the function returns TRUE for all characters in the categories: |
|
57 ECcCategory, ECfCategory, ECsCategory, ECoCategory and ECnCategoryCc. |
|
58 @return True, if the character is a control character; false, otherwise. |
|
59 @param c an integer whose value is representable as an unsigned char. |
|
60 */ |
|
61 EXPORT_C int iscntrl(int c) |
|
62 { |
|
63 return TChar((TUint)c).IsControl(); |
|
64 } |
|
65 |
|
66 /** |
|
67 Tests whether the character is a standard decimal digit. |
|
68 For Unicode, this function returns TRUE only for the digits |
|
69 '0'...'9' (U+0030...U+0039), not for other digits in scripts |
|
70 like Arabic, Tamil, etc. |
|
71 @return True, if the character is a standard decimal digit; false, otherwise. |
|
72 @param c an integer whose value is representable as an unsigned char. |
|
73 */ |
|
74 EXPORT_C int isdigit(int c) |
|
75 { |
|
76 return TChar((TUint)c).IsDigit(); |
|
77 } |
|
78 |
|
79 /** |
|
80 Tests whether the character is a graphic character. |
|
81 For Unicode, graphic characters include printable characters but not the space |
|
82 character. Specifically, graphic characters are any character except those in |
|
83 categories: EZsCategory,EZlCategory,EZpCategory, ECcCategory,ECfCategory,ECsCategory, |
|
84 ECoCategory, and ,ECnCategory. |
|
85 Note that for ISO Latin-1, all alphanumeric and punctuation characters are graphic. |
|
86 @return True, if the character is a graphic character; false, otherwise. |
|
87 @param c an integer whose value is representable as an unsigned char. |
|
88 */ |
|
89 EXPORT_C int isgraph(int c) |
|
90 { |
|
91 return TChar((TUint)c).IsGraph(); |
|
92 } |
|
93 |
|
94 /** |
|
95 Tests if character is a lowercase letter. |
|
96 @return True, if the character is lowercase; false, otherwise. |
|
97 @param c an integer whose value is representable as an unsigned char. |
|
98 */ |
|
99 EXPORT_C int islower(int c) |
|
100 { |
|
101 return TChar((TUint)c).IsLower(); |
|
102 } |
|
103 |
|
104 /** |
|
105 Tests whether the character is a printable character. |
|
106 For Unicode, printable characters are any character except those in categories: |
|
107 ECcCategory, ECfCategory, ECsCategory, ECoCategory and ECnCategory. |
|
108 Note that for ISO Latin-1, all alphanumeric and punctuation characters, |
|
109 plus space, are printable. |
|
110 @return True, if the character is printable; false, otherwise. |
|
111 @param c an integer whose value is representable as an unsigned char. |
|
112 */ |
|
113 EXPORT_C int isprint(int c) |
|
114 { |
|
115 return TChar((TUint)c).IsPrint(); |
|
116 } |
|
117 |
|
118 /** |
|
119 Tests whether the character is a punctuation character. |
|
120 For Unicode, punctuation characters are any character in the categories: |
|
121 EPcCategory, EPdCategory, EPsCategory, EPeCategory, EPiCategory, EPfCategory, |
|
122 EPoCategory. |
|
123 @return True, if the character is punctuation; false, otherwise. |
|
124 @param c an integer whose value is representable as an unsigned char. |
|
125 */ |
|
126 EXPORT_C int ispunct(int c) |
|
127 { |
|
128 return TChar((TUint)c).IsPunctuation(); |
|
129 } |
|
130 |
|
131 /** |
|
132 Tests whether the character is a white space character. White space includes |
|
133 spaces, tabs and separators. |
|
134 For Unicode, the function returns TRUE for all characters in the categories: |
|
135 EZsCategory, EZlCategory and EZpCategory, and also for the characters |
|
136 0x0009 (horizontal tab), 0x000A (linefeed), 0x000B (vertical tab), 0x000C (form feed), |
|
137 and 0x000D (carriage return). |
|
138 @return True, if the character is white space; false, otherwise. |
|
139 @param c an integer whose value is representable as an unsigned char, |
|
140 */ |
|
141 EXPORT_C int isspace(int c) |
|
142 { |
|
143 return TChar((TUint)c).IsSpace(); |
|
144 } |
|
145 |
|
146 /** |
|
147 Tests whether the character is uppercase. |
|
148 @return True, if the character is uppercase; false, otherwise. |
|
149 @param c an integer whose value is representable as an unsigned char. |
|
150 */ |
|
151 EXPORT_C int isupper(int c) |
|
152 { |
|
153 return TChar((TUint)c).IsUpper(); |
|
154 } |
|
155 |
|
156 /** |
|
157 Tests whether the character is a hexadecimal digit (0-9, a-f, A-F). |
|
158 @return True, if the character is a hexadecimal digit; false, otherwise. |
|
159 @param c the character to check. |
|
160 */ |
|
161 EXPORT_C int isxdigit(int c) |
|
162 { |
|
163 return TChar((TUint)c).IsHexDigit(); |
|
164 } |
|
165 |
|
166 /** |
|
167 Tests whether the character is lowercase. |
|
168 @return TBool True, if the character is lowercase; false, otherwise. |
|
169 @param c an argument to convert. |
|
170 */ |
|
171 EXPORT_C int tolower(int c) |
|
172 { |
|
173 return TChar((TUint)c).GetLowerCase(); |
|
174 } |
|
175 |
|
176 /** |
|
177 Returns the character value after conversion to uppercase or the character's |
|
178 own value, if no uppercase form exists. The character object itself is not changed. |
|
179 @return The character value after conversion to uppercase. |
|
180 @param c an argument to convert |
|
181 */ |
|
182 EXPORT_C int toupper(int c) |
|
183 { |
|
184 return TChar((TUint)c).GetUpperCase(); |
|
185 } |
|
186 |
|
187 } // extern "C" |