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