lib_ascii.h 47 KB

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