lib_ascii.h 47 KB

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