LPCOpen Platform
v1.03
LPCOpen Platform for NXP LPC Microcontrollers
Main Page
Modules
Data Structures
Files
Related Pages
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
lib_ascii.h
Go to the documentation of this file.
1
/*
2
*********************************************************************************************************
3
* uC/LIB
4
* CUSTOM LIBRARY MODULES
5
*
6
* (c) Copyright 2004-2011; Micrium, Inc.; Weston, FL
7
*
8
* All rights reserved. Protected by international copyright laws.
9
*
10
* uC/LIB is provided in source form to registered licensees ONLY. It is
11
* illegal to distribute this source code to any third party unless you receive
12
* written permission by an authorized Micrium representative. Knowledge of
13
* the source code may NOT be used to develop a similar product.
14
*
15
* Please help us continue to provide the Embedded community with the finest
16
* software available. Your honesty is greatly appreciated.
17
*
18
* You can contact us at www.micrium.com.
19
*********************************************************************************************************
20
*/
21
22
/*
23
*********************************************************************************************************
24
*
25
* ASCII CHARACTER OPERATIONS
26
*
27
* Filename : lib_ascii.h
28
* Version : V1.35.00
29
* Programmer(s) : BAN
30
*********************************************************************************************************
31
* Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software.
32
*
33
* (a) ALL standard library functions are implemented in the custom library modules :
34
*
35
* (1) <Custom Library Directory>\lib_*.*
36
*
37
* (2) <Custom Library Directory>\Ports<cpu><compiler>\lib*_a.*
38
*
39
* where
40
* <Custom Library Directory> directory path for custom library software
41
* <cpu> directory name for specific processor (CPU)
42
* <compiler> directory name for specific compiler
43
*
44
* (b) Product-specific library functions are implemented in individual products.
45
*
46
*
47
* (2) (a) ECMA-6 '7-Bit coded Character Set' (6th edition), which corresponds to the
48
* 3rd edition of ISO 646, specifies several versions of a 7-bit character set :
49
*
50
* (1) THE GENERAL VERSION, which allows characters at 0x23 and 0x24 to be given a
51
* set alternate form and allows the characters 0x40, 0x5B, 0x5D, 0x60, 0x7B &
52
* 0x7D to be assigned a "unique graphic character" or to be declared as unused.
53
* All other characters are explicitly specified.
54
*
55
* (2) THE INTERNATIONAL REFERENCE VERSION, which explicitly specifies all characters
56
* in the 7-bit character set.
57
*
58
* (3) NATIONAL & APPLICATION-ORIENTED VERSIONS, which may be derived from the
59
* standard in specified ways.
60
*
61
* (b) The character set represented in this file reproduces the Internation Reference
62
* Version. This is identical to the 7-bit character set which occupies Unicode
63
* characters 0x0000 through 0x007F. The character names are taken from v5.0 of the
64
* Unicode specification, with certain abbreviations so that the resulting #define
65
* names will not violate ANSI C naming restriction :
66
*
67
* (1) For the Latin capital & lowercase letters, the name components 'LETTER_CAPITAL'
68
* & 'LETTER_SMALL' are replaced by 'UPPER' & 'LOWER', respectively.
69
*********************************************************************************************************
70
*/
71
72
73
/*
74
*********************************************************************************************************
75
* MODULE
76
*
77
* Note(s) : (1) This ASCII library header file is protected from multiple pre-processor inclusion through
78
* use of the ASCII library module present pre-processor macro definition.
79
*********************************************************************************************************
80
*/
81
82
#ifndef LIB_ASCII_MODULE_PRESENT
/* See Note #1. */
83
#define LIB_ASCII_MODULE_PRESENT
84
85
86
/*$PAGE*/
87
/*
88
*********************************************************************************************************
89
* INCLUDE FILES
90
*
91
* Note(s) : (1) The custom library software files are located in the following directories :
92
*
93
* (a) <Custom Library Directory>\lib_*.*
94
*
95
* where
96
* <Custom Library Directory> directory path for custom library software
97
*
98
* (2) CPU-configuration software files are located in the following directories :
99
*
100
* (a) <CPU-Compiler Directory>\cpu_*.*
101
* (b) <CPU-Compiler Directory><cpu><compiler>\cpu*.*
102
*
103
* where
104
* <CPU-Compiler Directory> directory path for common CPU-compiler software
105
* <cpu> directory name for specific processor (CPU)
106
* <compiler> directory name for specific compiler
107
*
108
* (3) Compiler MUST be configured to include as additional include path directories :
109
*
110
* (a) '<Custom Library Directory>\' directory See Note #1a
111
*
112
* (b) (1) '<CPU-Compiler Directory>\' directory See Note #2a
113
* (2) '<CPU-Compiler Directory><cpu><compiler>\' directory See Note #2b
114
*
115
* (4) NO compiler-supplied standard library functions SHOULD be used.
116
*********************************************************************************************************
117
*/
118
119
#include <cpu.h>
120
#include <
lib_def.h
>
121
122
123
/*
124
*********************************************************************************************************
125
* EXTERNS
126
*********************************************************************************************************
127
*/
128
129
#ifdef LIB_ASCII_MODULE
130
#define LIB_ASCII_EXT
131
#else
132
#define LIB_ASCII_EXT extern
133
#endif
134
135
136
/*$PAGE*/
137
/*
138
*********************************************************************************************************
139
* DEFINES
140
*********************************************************************************************************
141
*/
142
143
/*
144
*********************************************************************************************************
145
* ASCII CHARACTER DEFINES
146
*********************************************************************************************************
147
*/
148
149
/* -------------------- C0 CONTROLS ------------------- */
150
#define ASCII_CHAR_NULL 0x00
/* '\0' */
151
#define ASCII_CHAR_START_OF_HEADING 0x01
152
#define ASCII_CHAR_START_OF_TEXT 0x02
153
#define ASCII_CHAR_END_OF_TEXT 0x03
154
#define ASCII_CHAR_END_OF_TRANSMISSION 0x04
155
#define ASCII_CHAR_ENQUIRY 0x05
156
#define ASCII_CHAR_ACKNOWLEDGE 0x06
157
#define ASCII_CHAR_BELL 0x07
/* '\a' */
158
#define ASCII_CHAR_BACKSPACE 0x08
/* '\b' */
159
#define ASCII_CHAR_CHARACTER_TABULATION 0x09
/* '\t' */
160
#define ASCII_CHAR_LINE_FEED 0x0A
/* '\n' */
161
#define ASCII_CHAR_LINE_TABULATION 0x0B
/* '\v' */
162
#define ASCII_CHAR_FORM_FEED 0x0C
/* '\f' */
163
#define ASCII_CHAR_CARRIAGE_RETURN 0x0D
/* '\r' */
164
#define ASCII_CHAR_SHIFT_OUT 0x0E
165
#define ASCII_CHAR_SHIFT_IN 0x0F
166
#define ASCII_CHAR_DATA_LINK_ESCAPE 0x10
167
#define ASCII_CHAR_DEVICE_CONTROL_ONE 0x11
168
#define ASCII_CHAR_DEVICE_CONTROL_TWO 0x12
169
#define ASCII_CHAR_DEVICE_CONTROL_THREE 0x13
170
#define ASCII_CHAR_DEVICE_CONTROL_FOUR 0x14
171
#define ASCII_CHAR_NEGATIVE_ACKNOWLEDGE 0x15
172
#define ASCII_CHAR_SYNCHRONOUS_IDLE 0x16
173
#define ASCII_CHAR_END_OF_TRANSMISSION_BLOCK 0x17
174
#define ASCII_CHAR_CANCEL 0x18
175
#define ASCII_CHAR_END_OF_MEDIUM 0x19
176
#define ASCII_CHAR_SUBSITUTE 0x1A
177
#define ASCII_CHAR_ESCAPE 0x1B
178
#define ASCII_CHAR_INFO_SEPARATOR_FOUR 0x1C
179
#define ASCII_CHAR_INFO_SEPARATOR_THREE 0x1D
180
#define ASCII_CHAR_INFO_SEPARATOR_TWO 0x1E
181
#define ASCII_CHAR_INFO_SEPARATOR_ONE 0x1F
182
183
#define ASCII_CHAR_NUL ASCII_CHAR_NULL
184
#define ASCII_CHAR_SOH ASCII_CHAR_START_OF_HEADING
185
#define ASCII_CHAR_START_HEADING ASCII_CHAR_START_OF_HEADING
186
#define ASCII_CHAR_STX ASCII_CHAR_START_OF_TEXT
187
#define ASCII_CHAR_START_TEXT ASCII_CHAR_START_OF_TEXT
188
#define ASCII_CHAR_ETX ASCII_CHAR_END_OF_TEXT
189
#define ASCII_CHAR_END_TEXT ASCII_CHAR_END_OF_TEXT
190
#define ASCII_CHAR_EOT ASCII_CHAR_END_OF_TRANSMISSION
191
#define ASCII_CHAR_END_TRANSMISSION ASCII_CHAR_END_OF_TRANSMISSION
192
#define ASCII_CHAR_ENQ ASCII_CHAR_ENQUIRY
193
#define ASCII_CHAR_ACK ASCII_CHAR_ACKNOWLEDGE
194
#define ASCII_CHAR_BEL ASCII_CHAR_BELL
195
#define ASCII_CHAR_BS ASCII_CHAR_BACKSPACE
196
#define ASCII_CHAR_HT ASCII_CHAR_CHARACTER_TABULATION
197
#define ASCII_CHAR_TAB ASCII_CHAR_CHARACTER_TABULATION
198
#define ASCII_CHAR_LF ASCII_CHAR_LINE_FEED
199
#define ASCII_CHAR_VT ASCII_CHAR_LINE_TABULATION
200
#define ASCII_CHAR_FF ASCII_CHAR_FORM_FEED
201
#define ASCII_CHAR_CR ASCII_CHAR_CARRIAGE_RETURN
202
#define ASCII_CHAR_SO ASCII_CHAR_SHIFT_OUT
203
#define ASCII_CHAR_SI ASCII_CHAR_SHIFT_IN
204
#define ASCII_CHAR_DLE ASCII_CHAR_DATA_LINK_ESCAPE
205
#define ASCII_CHAR_DC1 ASCII_CHAR_DEVICE_CONTROL_ONE
206
#define ASCII_CHAR_DC2 ASCII_CHAR_DEVICE_CONTROL_TWO
207
#define ASCII_CHAR_DC3 ASCII_CHAR_DEVICE_CONTROL_THREE
208
#define ASCII_CHAR_DC4 ASCII_CHAR_DEVICE_CONTROL_FOUR
209
#define ASCII_CHAR_DEV_CTRL_ONE ASCII_CHAR_DEVICE_CONTROL_ONE
210
#define ASCII_CHAR_DEV_CTRL_TWO ASCII_CHAR_DEVICE_CONTROL_TWO
211
#define ASCII_CHAR_DEV_CTRL_THREE ASCII_CHAR_DEVICE_CONTROL_THREE
212
#define ASCII_CHAR_DEV_CTRL_FOUR ASCII_CHAR_DEVICE_CONTROL_FOUR
213
#define ASCII_CHAR_NAK ASCII_CHAR_NEGATIVE_ACKNOWLEDGE
214
#define ASCII_CHAR_NEG_ACK ASCII_CHAR_NEGATIVE_ACKNOWLEDGE
215
#define ASCII_CHAR_SYN ASCII_CHAR_SYNCHRONOUS_IDLE
216
#define ASCII_CHAR_SYNC_IDLE ASCII_CHAR_SYNCHRONOUS_IDLE
217
#define ASCII_CHAR_ETB ASCII_CHAR_END_OF_TRANSMISSION_BLOCK
218
#define ASCII_CHAR_END_TRANSMISSION_BLK ASCII_CHAR_END_OF_TRANSMISSION_BLOCK
219
#define ASCII_CHAR_CAN ASCII_CHAR_CANCEL
220
#define ASCII_CHAR_EM ASCII_CHAR_END_OF_MEDIUM
221
#define ASCII_CHAR_END_MEDIUM ASCII_CHAR_END_OF_MEDIUM
222
#define ASCII_CHAR_SUB ASCII_CHAR_SUBSITUTE
223
#define ASCII_CHAR_ESC ASCII_CHAR_ESCAPE
224
#define ASCII_CHAR_IS1 ASCII_CHAR_INFO_SEPARATOR_ONE
225
#define ASCII_CHAR_IS2 ASCII_CHAR_INFO_SEPARATOR_TWO
226
#define ASCII_CHAR_IS3 ASCII_CHAR_INFO_SEPARATOR_THREE
227
#define ASCII_CHAR_IS4 ASCII_CHAR_INFO_SEPARATOR_FOUR
228
229
230
/*$PAGE*/
231
/* ------------ ASCII PUNCTUATION & SYMBOLS ----------- */
232
#define ASCII_CHAR_SPACE 0x20
/* ' ' */
233
#define ASCII_CHAR_EXCLAMATION_MARK 0x21
/* '!' */
234
#define ASCII_CHAR_QUOTATION_MARK 0x22
/* '\"' */
235
#define ASCII_CHAR_NUMBER_SIGN 0x23
/* '#' */
236
#define ASCII_CHAR_DOLLAR_SIGN 0x24
/* '$' */
237
#define ASCII_CHAR_PERCENTAGE_SIGN 0x25
/* '%' */
238
#define ASCII_CHAR_AMPERSAND 0x26
/* '&' */
239
#define ASCII_CHAR_APOSTROPHE 0x27
/* '\'' */
240
#define ASCII_CHAR_LEFT_PARENTHESIS 0x28
/* '(' */
241
#define ASCII_CHAR_RIGHT_PARENTHESIS 0x29
/* ')' */
242
#define ASCII_CHAR_ASTERISK 0x2A
/* '*' */
243
#define ASCII_CHAR_PLUS_SIGN 0x2B
/* '+' */
244
#define ASCII_CHAR_COMMA 0x2C
/* ',' */
245
#define ASCII_CHAR_HYPHEN_MINUS 0x2D
/* '-' */
246
#define ASCII_CHAR_FULL_STOP 0x2E
/* '.' */
247
#define ASCII_CHAR_SOLIDUS 0x2F
/* '/' */
248
249
#define ASCII_CHAR_PAREN_LEFT ASCII_CHAR_LEFT_PARENTHESIS
250
#define ASCII_CHAR_PAREN_RIGHT ASCII_CHAR_RIGHT_PARENTHESIS
251
252
253
/* ------------------- ASCII DIGITS ------------------- */
254
#define ASCII_CHAR_DIGIT_ZERO 0x30
/* '0' */
255
#define ASCII_CHAR_DIGIT_ONE 0x31
/* '1' */
256
#define ASCII_CHAR_DIGIT_TWO 0x32
/* '2' */
257
#define ASCII_CHAR_DIGIT_THREE 0x33
/* '3' */
258
#define ASCII_CHAR_DIGIT_FOUR 0x34
/* '4' */
259
#define ASCII_CHAR_DIGIT_FIVE 0x35
/* '5' */
260
#define ASCII_CHAR_DIGIT_SIX 0x36
/* '6' */
261
#define ASCII_CHAR_DIGIT_SEVEN 0x37
/* '7' */
262
#define ASCII_CHAR_DIGIT_EIGHT 0x38
/* '8' */
263
#define ASCII_CHAR_DIGIT_NINE 0x39
/* '9' */
264
265
#define ASCII_CHAR_DIG_ZERO ASCII_CHAR_DIGIT_ZERO
266
#define ASCII_CHAR_DIG_ONE ASCII_CHAR_DIGIT_ONE
267
#define ASCII_CHAR_DIG_TWO ASCII_CHAR_DIGIT_TWO
268
#define ASCII_CHAR_DIG_THREE ASCII_CHAR_DIGIT_THREE
269
#define ASCII_CHAR_DIG_FOUR ASCII_CHAR_DIGIT_FOUR
270
#define ASCII_CHAR_DIG_FIVE ASCII_CHAR_DIGIT_FIVE
271
#define ASCII_CHAR_DIG_SIX ASCII_CHAR_DIGIT_SIX
272
#define ASCII_CHAR_DIG_SEVEN ASCII_CHAR_DIGIT_SEVEN
273
#define ASCII_CHAR_DIG_EIGHT ASCII_CHAR_DIGIT_EIGHT
274
#define ASCII_CHAR_DIG_NINE ASCII_CHAR_DIGIT_NINE
275
276
277
/* ------------ ASCII PUNCTUATION & SYMBOLS ----------- */
278
#define ASCII_CHAR_COLON 0x3A
/* ':' */
279
#define ASCII_CHAR_SEMICOLON 0x3B
/* ';' */
280
#define ASCII_CHAR_LESS_THAN_SIGN 0x3C
/* '<' */
281
#define ASCII_CHAR_EQUALS_SIGN 0x3D
/* '=' */
282
#define ASCII_CHAR_GREATER_THAN_SIGN 0x3E
/* '>' */
283
#define ASCII_CHAR_QUESTION_MARK 0x3F
/* '\?' */
284
#define ASCII_CHAR_COMMERCIAL_AT 0x40
/* '@' */
285
286
#define ASCII_CHAR_AT_SIGN ASCII_CHAR_COMMERCIAL_AT
287
288
289
/*$PAGE*/
290
/* ------------- UPPERCASE LATIN ALPHABET ------------- */
291
#define ASCII_CHAR_LATIN_UPPER_A 0x41
/* 'A' */
292
#define ASCII_CHAR_LATIN_UPPER_B 0x42
/* 'B' */
293
#define ASCII_CHAR_LATIN_UPPER_C 0x43
/* 'C' */
294
#define ASCII_CHAR_LATIN_UPPER_D 0x44
/* 'D' */
295
#define ASCII_CHAR_LATIN_UPPER_E 0x45
/* 'E' */
296
#define ASCII_CHAR_LATIN_UPPER_F 0x46
/* 'F' */
297
#define ASCII_CHAR_LATIN_UPPER_G 0x47
/* 'G' */
298
#define ASCII_CHAR_LATIN_UPPER_H 0x48
/* 'H' */
299
#define ASCII_CHAR_LATIN_UPPER_I 0x49
/* 'I' */
300
#define ASCII_CHAR_LATIN_UPPER_J 0x4A
/* 'J' */
301
#define ASCII_CHAR_LATIN_UPPER_K 0x4B
/* 'K' */
302
#define ASCII_CHAR_LATIN_UPPER_L 0x4C
/* 'L' */
303
#define ASCII_CHAR_LATIN_UPPER_M 0x4D
/* 'M' */
304
#define ASCII_CHAR_LATIN_UPPER_N 0x4E
/* 'N' */
305
#define ASCII_CHAR_LATIN_UPPER_O 0x4F
/* 'O' */
306
#define ASCII_CHAR_LATIN_UPPER_P 0x50
/* 'P' */
307
#define ASCII_CHAR_LATIN_UPPER_Q 0x51
/* 'Q' */
308
#define ASCII_CHAR_LATIN_UPPER_R 0x52
/* 'R' */
309
#define ASCII_CHAR_LATIN_UPPER_S 0x53
/* 'S' */
310
#define ASCII_CHAR_LATIN_UPPER_T 0x54
/* 'T' */
311
#define ASCII_CHAR_LATIN_UPPER_U 0x55
/* 'U' */
312
#define ASCII_CHAR_LATIN_UPPER_V 0x56
/* 'V' */
313
#define ASCII_CHAR_LATIN_UPPER_W 0x57
/* 'W' */
314
#define ASCII_CHAR_LATIN_UPPER_X 0x58
/* 'X' */
315
#define ASCII_CHAR_LATIN_UPPER_Y 0x59
/* 'Y' */
316
#define ASCII_CHAR_LATIN_UPPER_Z 0x5A
/* 'Z' */
317
318
319
/* ------------ ASCII PUNCTUATION & SYMBOLS ----------- */
320
#define ASCII_CHAR_LEFT_SQUARE_BRACKET 0x5B
/* '[' */
321
#define ASCII_CHAR_REVERSE_SOLIDUS 0x5C
/* '\\' */
322
#define ASCII_CHAR_RIGHT_SQUARE_BRACKET 0x5D
/* ']' */
323
#define ASCII_CHAR_CIRCUMFLEX_ACCENT 0x5E
/* '^' */
324
#define ASCII_CHAR_LOW_LINE 0x5F
/* '_' */
325
#define ASCII_CHAR_GRAVE_ACCENT 0x60
/* '`' */
326
327
#define ASCII_CHAR_BRACKET_SQUARE_LEFT ASCII_CHAR_LEFT_SQUARE_BRACKET
328
#define ASCII_CHAR_BRACKET_SQUARE_RIGHT ASCII_CHAR_RIGHT_SQUARE_BRACKET
329
330
331
/* ------------- LOWERCASE LATIN ALPHABET ------------- */
332
#define ASCII_CHAR_LATIN_LOWER_A 0x61
/* 'a' */
333
#define ASCII_CHAR_LATIN_LOWER_B 0x62
/* 'b' */
334
#define ASCII_CHAR_LATIN_LOWER_C 0x63
/* 'c' */
335
#define ASCII_CHAR_LATIN_LOWER_D 0x64
/* 'd' */
336
#define ASCII_CHAR_LATIN_LOWER_E 0x65
/* 'e' */
337
#define ASCII_CHAR_LATIN_LOWER_F 0x66
/* 'f' */
338
#define ASCII_CHAR_LATIN_LOWER_G 0x67
/* 'g' */
339
#define ASCII_CHAR_LATIN_LOWER_H 0x68
/* 'h' */
340
#define ASCII_CHAR_LATIN_LOWER_I 0x69
/* 'i' */
341
#define ASCII_CHAR_LATIN_LOWER_J 0x6A
/* 'j' */
342
#define ASCII_CHAR_LATIN_LOWER_K 0x6B
/* 'k' */
343
#define ASCII_CHAR_LATIN_LOWER_L 0x6C
/* 'l' */
344
#define ASCII_CHAR_LATIN_LOWER_M 0x6D
/* 'm' */
345
#define ASCII_CHAR_LATIN_LOWER_N 0x6E
/* 'n' */
346
#define ASCII_CHAR_LATIN_LOWER_O 0x6F
/* 'o' */
347
#define ASCII_CHAR_LATIN_LOWER_P 0x70
/* 'p' */
348
#define ASCII_CHAR_LATIN_LOWER_Q 0x71
/* 'q' */
349
#define ASCII_CHAR_LATIN_LOWER_R 0x72
/* 'r' */
350
#define ASCII_CHAR_LATIN_LOWER_S 0x73
/* 's' */
351
#define ASCII_CHAR_LATIN_LOWER_T 0x74
/* 't' */
352
#define ASCII_CHAR_LATIN_LOWER_U 0x75
/* 'u' */
353
#define ASCII_CHAR_LATIN_LOWER_V 0x76
/* 'v' */
354
#define ASCII_CHAR_LATIN_LOWER_W 0x77
/* 'w' */
355
#define ASCII_CHAR_LATIN_LOWER_X 0x78
/* 'x' */
356
#define ASCII_CHAR_LATIN_LOWER_Y 0x79
/* 'y' */
357
#define ASCII_CHAR_LATIN_LOWER_Z 0x7A
/* 'z' */
358
359
360
/* ------------ ASCII PUNCTUATION & SYMBOLS ----------- */
361
#define ASCII_CHAR_LEFT_CURLY_BRACKET 0x7B
/* '{' */
362
#define ASCII_CHAR_VERTICAL_LINE 0x7C
/* '|' */
363
#define ASCII_CHAR_RIGHT_CURLY_BRACKET 0x7D
/* '}' */
364
#define ASCII_CHAR_TILDE 0x7E
/* '~' */
365
366
#define ASCII_CHAR_BRACKET_CURLY_LEFT ASCII_CHAR_LEFT_CURLY_BRACKET
367
#define ASCII_CHAR_BRACKET_CURLY_RIGHT ASCII_CHAR_RIGHT_CURLY_BRACKET
368
369
370
/* ---------------- CONTROL CHARACTERS ---------------- */
371
#define ASCII_CHAR_DELETE 0x7F
372
373
#define ASCII_CHAR_DEL ASCII_CHAR_DELETE
374
375
376
/*$PAGE*/
377
/*
378
*********************************************************************************************************
379
* DATA TYPES
380
*********************************************************************************************************
381
*/
382
383
384
/*
385
*********************************************************************************************************
386
* GLOBAL VARIABLES
387
*********************************************************************************************************
388
*/
389
390
391
/*$PAGE*/
392
/*
393
*********************************************************************************************************
394
* MACRO'S
395
*********************************************************************************************************
396
*/
397
398
/*
399
*********************************************************************************************************
400
* ASCII CHARACTER CLASSIFICATION MACRO's
401
*
402
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.(1) states that "character classification functions ...
403
* return nonzero (true) if and only if the value of the argument 'c' conforms to ... the
404
* description of the function."
405
*********************************************************************************************************
406
*/
407
408
/*
409
*********************************************************************************************************
410
* ASCII_IS_DIG()
411
*
412
* Description : Determine whether a character is a decimal-digit character.
413
*
414
* Argument(s) : c Character to examine.
415
*
416
* Return(s) : DEF_YES, if character is a decimal-digit character.
417
*
418
* DEF_NO, if character is NOT a decimal-digit character.
419
*
420
* Caller(s) : Application.
421
*
422
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.5.(2) states that "isdigit() ... tests for any
423
* decimal-digit character".
424
*********************************************************************************************************
425
*/
426
427
#define ASCII_IS_DIG(c) ((((c) >= ASCII_CHAR_DIG_ZERO) && ((c) <= ASCII_CHAR_DIG_NINE)) ? (DEF_YES) : (DEF_NO))
428
429
430
/*
431
*********************************************************************************************************
432
* ASCII_IS_DIG_OCT()
433
*
434
* Description : Determine whether a character is an octal-digit character.
435
*
436
* Argument(s) : c Character to examine.
437
*
438
* Return(s) : DEF_YES, if character is an octal-digit character.
439
*
440
* DEF_NO, if character is NOT an octal-digit character.
441
*
442
* Caller(s) : Application.
443
*
444
* Note(s) : none.
445
*********************************************************************************************************
446
*/
447
448
#define ASCII_IS_DIG_OCT(c) ((((c) >= ASCII_CHAR_DIG_ZERO) && ((c) <= ASCII_CHAR_DIG_SEVEN)) ? (DEF_YES) : (DEF_NO))
449
450
451
/*
452
*********************************************************************************************************
453
* ASCII_IS_DIG_HEX()
454
*
455
* Description : Determine whether a character is a hexadecimal-digit character.
456
*
457
* Argument(s) : c Character to examine.
458
*
459
* Return(s) : DEF_YES, if character is a hexadecimal-digit character.
460
*
461
* DEF_NO, if character is NOT a hexadecimal-digit character.
462
*
463
* Caller(s) : Application.
464
*
465
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.12.(2) states that "isxdigit() ... tests for any
466
* hexadecimal-digit character".
467
*********************************************************************************************************
468
*/
469
470
#define ASCII_IS_DIG_HEX(c) (((((c) >= ASCII_CHAR_DIG_ZERO ) && ((c) <= ASCII_CHAR_DIG_NINE )) || \
471
(((c) >= ASCII_CHAR_LATIN_UPPER_A) && ((c) <= ASCII_CHAR_LATIN_UPPER_F)) || \
472
(((c) >= ASCII_CHAR_LATIN_LOWER_A) && ((c) <= ASCII_CHAR_LATIN_LOWER_F))) ? (DEF_YES) : (DEF_NO))
473
474
475
/*$PAGE*/
476
/*
477
*********************************************************************************************************
478
* ASCII_IS_LOWER()
479
*
480
* Description : Determine whether a character is a lowercase alphabetic character.
481
*
482
* Argument(s) : c Character to examine.
483
*
484
* Return(s) : DEF_YES, if character is a lowercase alphabetic character.
485
*
486
* DEF_NO, if character is NOT a lowercase alphabetic character.
487
*
488
* Caller(s) : Application.
489
*
490
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.7.(2) states that "islower() returns true only for
491
* the lowercase letters".
492
*********************************************************************************************************
493
*/
494
495
#define ASCII_IS_LOWER(c) ((((c) >= ASCII_CHAR_LATIN_LOWER_A) && ((c) <= ASCII_CHAR_LATIN_LOWER_Z)) ? (DEF_YES) : (DEF_NO))
496
497
498
/*
499
*********************************************************************************************************
500
* ASCII_IS_UPPER()
501
*
502
* Description : Determine whether a character is an uppercase alphabetic character.
503
*
504
* Argument(s) : c Character to examine.
505
*
506
* Return(s) : DEF_YES, if character is an uppercase alphabetic character.
507
*
508
* DEF_NO, if character is NOT an uppercase alphabetic character.
509
*
510
* Caller(s) : Application.
511
*
512
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.11.(2) states that "isupper() returns true only for
513
* the uppercase letters".
514
*********************************************************************************************************
515
*/
516
517
#define ASCII_IS_UPPER(c) ((((c) >= ASCII_CHAR_LATIN_UPPER_A) && ((c) <= ASCII_CHAR_LATIN_UPPER_Z)) ? (DEF_YES) : (DEF_NO))
518
519
520
/*$PAGE*/
521
/*
522
*********************************************************************************************************
523
* ASCII_IS_ALPHA()
524
*
525
* Description : Determine whether a character is an alphabetic character.
526
*
527
* Argument(s) : c Character to examine.
528
*
529
* Return(s) : DEF_YES, if character is an alphabetic character.
530
*
531
* DEF_NO, if character is NOT an alphabetic character.
532
*
533
* Caller(s) : Application.
534
*
535
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.2.(2) states that "isalpha() returns true only for the
536
* characters for which isupper() or islower() is true".
537
*********************************************************************************************************
538
*/
539
540
#define ASCII_IS_ALPHA(c) ((((ASCII_IS_UPPER(c)) == DEF_YES) || \
541
((ASCII_IS_LOWER(c)) == DEF_YES)) ? (DEF_YES) : (DEF_NO))
542
543
544
/*
545
*********************************************************************************************************
546
* ASCII_IS_ALPHA_NUM()
547
*
548
* Description : Determine whether a character is an alphanumeric character.
549
*
550
* Argument(s) : c Character to examine.
551
*
552
* Return(s) : DEF_YES, if character is an alphanumeric character.
553
*
554
* DEF_NO, if character is NOT an alphanumeric character.
555
*
556
* Caller(s) : Application.
557
*
558
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.1.(2) states that "isalnum() ... tests for any character
559
* for which isalpha() or isdigit() is true".
560
*********************************************************************************************************
561
*/
562
563
#define ASCII_IS_ALPHA_NUM(c) ((((ASCII_IS_ALPHA(c)) == DEF_YES) || \
564
((ASCII_IS_DIG (c)) == DEF_YES)) ? (DEF_YES) : (DEF_NO))
565
566
567
/*$PAGE*/
568
/*
569
*********************************************************************************************************
570
* ASCII_IS_BLANK()
571
*
572
* Description : Determine whether a character is a standard blank character.
573
*
574
* Argument(s) : c Character to examine.
575
*
576
* Return(s) : DEF_YES, if character is a standard blank character.
577
*
578
* DEF_NO, if character is NOT a standard blank character.
579
*
580
* Caller(s) : Application.
581
*
582
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.3.(2) states that "isblank() returns true only for
583
* the standard blank characters".
584
*
585
* (b) ISO/IEC 9899:TC2, Section 7.4.1.3.(2) defines "the standard blank characters" as
586
* the "space (' '), and horizontal tab ('\t')".
587
*********************************************************************************************************
588
*/
589
590
#define ASCII_IS_BLANK(c) ((((c) == ASCII_CHAR_SPACE) || ((c) == ASCII_CHAR_HT)) ? (DEF_YES) : (DEF_NO))
591
592
593
/*
594
*********************************************************************************************************
595
* ASCII_IS_SPACE()
596
*
597
* Description : Determine whether a character is a white-space character.
598
*
599
* Argument(s) : c Character to examine.
600
*
601
* Return(s) : DEF_YES, if character is a white-space character.
602
*
603
* DEF_NO, if character is NOT a white-space character.
604
*
605
* Caller(s) : Application.
606
*
607
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.10.(2) states that "isspace() returns true only
608
* for the standard white-space characters".
609
*
610
* (b) ISO/IEC 9899:TC2, Section 7.4.1.10.(2) defines "the standard white-space characters"
611
* as the "space (' '), form feed ('\f'), new-line ('\n'), carriage return ('\r'),
612
* horizontal tab ('\t'), and vertical tab ('\v')".
613
*********************************************************************************************************
614
*/
615
616
#define ASCII_IS_SPACE(c) ((((c) == ASCII_CHAR_SPACE) || ((c) == ASCII_CHAR_CR) || \
617
((c) == ASCII_CHAR_LF ) || ((c) == ASCII_CHAR_FF) || \
618
((c) == ASCII_CHAR_HT ) || ((c) == ASCII_CHAR_VT)) ? (DEF_YES) : (DEF_NO))
619
620
621
/*$PAGE*/
622
/*
623
*********************************************************************************************************
624
* ASCII_IS_PRINT()
625
*
626
* Description : Determine whether a character is a printing character.
627
*
628
* Argument(s) : c Character to examine.
629
*
630
* Return(s) : DEF_YES, if character is a printing character.
631
*
632
* DEF_NO, if character is NOT a printing character.
633
*
634
* Caller(s) : Application.
635
*
636
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.8.(2) states that "isprint() ... tests for any
637
* printing character including space (' ')".
638
*
639
* (b) ISO/IEC 9899:TC2, Section 7.4.(3), Note 169, states that in "the seven-bit US
640
* ASCII character set, the printing characters are those whose values lie from
641
* 0x20 (space) through 0x7E (tilde)".
642
*********************************************************************************************************
643
*/
644
645
#define ASCII_IS_PRINT(c) ((((c) >= ASCII_CHAR_SPACE) && ((c) <= ASCII_CHAR_TILDE)) ? (DEF_YES) : (DEF_NO))
646
647
648
/*
649
*********************************************************************************************************
650
* ASCII_IS_GRAPH()
651
*
652
* Description : Determine whether a character is any printing character except a space character.
653
*
654
* Argument(s) : c Character to examine.
655
*
656
* Return(s) : DEF_YES, if character is a graphic character.
657
*
658
* DEF_NO, if character is NOT a graphic character.
659
*
660
* Caller(s) : Application.
661
*
662
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.6.(2) states that "isgraph() ... tests for any
663
* printing character except space (' ')".
664
*
665
* (b) ISO/IEC 9899:TC2, Section 7.4.(3), Note 169, states that in "the seven-bit US
666
* ASCII character set, the printing characters are those whose values lie from
667
* 0x20 (space) through 0x7E (tilde)".
668
*********************************************************************************************************
669
*/
670
671
#define ASCII_IS_GRAPH(c) ((((c) >= ASCII_CHAR_EXCLAMATION_MARK) && ((c) <= ASCII_CHAR_TILDE)) ? (DEF_YES) : (DEF_NO))
672
673
674
/*$PAGE*/
675
/*
676
*********************************************************************************************************
677
* ASCII_IS_PUNCT()
678
*
679
* Description : Determine whether a character is a punctuation character.
680
*
681
* Argument(s) : c Character to examine.
682
*
683
* Return(s) : DEF_YES, if character is a punctuation character.
684
*
685
* DEF_NO, if character is NOT a punctuation character.
686
*
687
* Caller(s) : Application.
688
*
689
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.9.(2) states that "ispunct() returns true for every
690
* printing character for which neither isspace() nor isalnum() is true".
691
*********************************************************************************************************
692
*/
693
694
#define ASCII_IS_PUNCT(c) ((((ASCII_IS_PRINT(c)) == DEF_YES) && \
695
((ASCII_IS_SPACE(c)) == DEF_NO ) && \
696
((ASCII_IS_ALPHA_NUM(c)) == DEF_NO )) ? (DEF_YES) : (DEF_NO))
697
698
699
/*
700
*********************************************************************************************************
701
* ASCII_IS_CTRL()
702
*
703
* Description : Determine whether a character is a control character.
704
*
705
* Argument(s) : c Character to examine.
706
*
707
* Return(s) : DEF_YES, if character is a control character.
708
*
709
* DEF_NO, if character is NOT a control character.
710
*
711
* Caller(s) : Application.
712
*
713
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.4.(2) states that "iscntrl() ... tests for any
714
* control character".
715
*
716
* (b) ISO/IEC 9899:TC2, Section 7.4.(3), Note 169, states that in "the seven-bit US
717
* ASCII character set, ... the control characters are those whose values lie from
718
* 0 (NUL) through 0x1F (US), and the character 0x7F (DEL)".
719
*********************************************************************************************************
720
*/
721
722
#define ASCII_IS_CTRL(c) (((((CPU_INT08S)(c) >= ASCII_CHAR_NULL ) && ((c) <= ASCII_CHAR_IS1)) || \
723
((c) == ASCII_CHAR_DEL)) ? (DEF_YES) : (DEF_NO))
724
725
726
/*$PAGE*/
727
/*
728
*********************************************************************************************************
729
* ASCII CHARACTER CASE MAPPING MACRO's
730
*********************************************************************************************************
731
*/
732
733
/*
734
*********************************************************************************************************
735
* ASCII_TO_LOWER()
736
*
737
* Description : Convert uppercase alphabetic character to its corresponding lowercase alphabetic character.
738
*
739
* Argument(s) : c Character to convert.
740
*
741
* Return(s) : Lowercase equivalent of 'c', if character 'c' is an uppercase character (see Note #1b1).
742
*
743
* Character 'c', otherwise (see Note #1b2).
744
*
745
* Caller(s) : Application.
746
*
747
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.2.1.(2) states that "tolower() ... converts an
748
* uppercase letter to a corresponding lowercase letter".
749
*
750
* (b) ISO/IEC 9899:TC2, Section 7.4.2.1.(3) states that :
751
*
752
* (1) (A) "if the argument is a character for which isupper() is true and there are
753
* one or more corresponding characters ... for which islower() is true," ...
754
* (B) "tolower() ... returns one of the corresponding characters;" ...
755
*
756
* (2) "otherwise, the argument is returned unchanged."
757
*********************************************************************************************************
758
*/
759
760
#define ASCII_TO_LOWER(c) (((ASCII_IS_UPPER(c)) == DEF_YES) ? ((c) + (ASCII_CHAR_LATIN_LOWER_A - ASCII_CHAR_LATIN_UPPER_A)) : (c))
761
762
763
/*
764
*********************************************************************************************************
765
* ASCII_TO_UPPER()
766
*
767
* Description : Convert lowercase alphabetic character to its corresponding uppercase alphabetic character.
768
*
769
* Argument(s) : c Character to convert.
770
*
771
* Return(s) : Uppercase equivalent of 'c', if character 'c' is a lowercase character (see Note #1b1).
772
*
773
* Character 'c', otherwise (see Note #1b2).
774
*
775
* Caller(s) : Application.
776
*
777
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.2.2.(2) states that "toupper() ... converts a
778
* lowercase letter to a corresponding uppercase letter".
779
*
780
* (b) ISO/IEC 9899:TC2, Section 7.4.2.2.(3) states that :
781
*
782
* (1) (A) "if the argument is a character for which islower() is true and there are
783
* one or more corresponding characters ... for which isupper() is true," ...
784
* (B) "toupper() ... returns one of the corresponding characters;" ...
785
*
786
* (2) "otherwise, the argument is returned unchanged."
787
*********************************************************************************************************
788
*/
789
790
#define ASCII_TO_UPPER(c) (((ASCII_IS_LOWER(c)) == DEF_YES) ? ((c) - (ASCII_CHAR_LATIN_LOWER_A - ASCII_CHAR_LATIN_UPPER_A)) : (c))
791
792
793
/*$PAGE*/
794
/*
795
*********************************************************************************************************
796
* FUNCTION PROTOTYPES
797
*********************************************************************************************************
798
*/
799
800
CPU_BOOLEAN
ASCII_IsAlpha
(
CPU_CHAR
c);
801
802
CPU_BOOLEAN
ASCII_IsAlphaNum
(
CPU_CHAR
c);
803
804
CPU_BOOLEAN
ASCII_IsLower
(
CPU_CHAR
c);
805
806
CPU_BOOLEAN
ASCII_IsUpper
(
CPU_CHAR
c);
807
808
CPU_BOOLEAN
ASCII_IsDig
(
CPU_CHAR
c);
809
810
CPU_BOOLEAN
ASCII_IsDigOct
(
CPU_CHAR
c);
811
812
CPU_BOOLEAN
ASCII_IsDigHex
(
CPU_CHAR
c);
813
814
CPU_BOOLEAN
ASCII_IsBlank
(
CPU_CHAR
c);
815
816
CPU_BOOLEAN
ASCII_IsSpace
(
CPU_CHAR
c);
817
818
CPU_BOOLEAN
ASCII_IsPrint
(
CPU_CHAR
c);
819
820
CPU_BOOLEAN
ASCII_IsGraph
(
CPU_CHAR
c);
821
822
CPU_BOOLEAN
ASCII_IsPunct
(
CPU_CHAR
c);
823
824
CPU_BOOLEAN
ASCII_IsCtrl
(
CPU_CHAR
c);
825
826
827
CPU_CHAR
ASCII_ToLower
(
CPU_CHAR
c);
828
829
CPU_CHAR
ASCII_ToUpper
(
CPU_CHAR
c);
830
831
832
CPU_BOOLEAN
ASCII_Cmp
(
CPU_CHAR
c1,
833
CPU_CHAR
c2);
834
835
836
/*$PAGE*/
837
/*
838
*********************************************************************************************************
839
* CONFIGURATION ERRORS
840
*********************************************************************************************************
841
*/
842
843
844
/*
845
*********************************************************************************************************
846
* MODULE END
847
*********************************************************************************************************
848
*/
849
850
#endif
/* End of lib ascii module include. */
851
software
ucos_iii
Micrium
Software
uC-LIB
lib_ascii.h
Generated on Fri May 10 2013 10:42:26 for LPCOpen Platform by
1.8.2