EACType.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
  2. <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  3. <Title>EAString</title>
  4. <link type="text/css" rel="stylesheet" href="UTFDoc.css">
  5. <meta name="author" content="Paul Pedriana">
  6. </head>
  7. <body bgcolor="#FFFFFF">
  8. <h1>EAString</h1>
  9. <h2>Introduction</h2>
  10. <p>EACRT stands for EA C Runtime. EACRT implements an extensive suite of C string functionality in a portable way. Some of this functionality is the same as what
  11. is present in the C standard and in common (but non-portable) extensions to the C standard. EACRT presents a consistent portable interface to its functionality
  12. in both 8 bit and 16 bit string form.</p>
  13. <p>The C language provides various functions which work with non-portable data types, such as long. EACRT defines all significant data types in terms of portable
  14. types such as int32_t and int64_t. </p>
  15. <p>Additionally, the EACRT versions of functions are usually faster than the C runtime library versions, usually because the EACRT versions minimize cache misses
  16. and branching, whereas typical C runtime libraries optimize for the smallest memory footprint with little or no regard to other performance characteristics.</p>
  17. <p>C-style printf functionality is separate from EACRT and is found in <a href="EASprintf.html">EASprintf</a>. Memcpy functionality (which comes from the C string.h
  18. header file) is present in <a href="Memcpy.html">EAMemcpy</a>. However, EACRT has a few mem functions itself.</p>
  19. <p>In some cases, EACRT simply #defines its function to be the same as the equivalent C function. This is done when the equivalent C function is known to be present
  20. and known to conform to the C/C++ language standard correctly.</p>
  21. <h2>Extension functions</h2>
  22. <p> EACRT provides extended functionality that isn't found in conventional C libraries, but it useful nevertheless.</p>
  23. <table width="100%" border="1" cellpadding="3">
  24. <tr>
  25. <td><b>Function</b></td>
  26. <td><b>Description</b></td>
  27. <td><b>Signature</b></td>
  28. </tr>
  29. <tr>
  30. <td>Strlcat</td>
  31. <td>Safe variation of strncat</td>
  32. <td><font size="-1">char_t* Strlcat(char_t* pDestination, const char_t* pSource, size_t n); </font></td>
  33. </tr>
  34. <tr>
  35. <td>Strlcpy</td>
  36. <td>Safe variation of strcpy</td>
  37. <td><font size="-1">char_t* Strlcpy(char_t* pDestination, const char_t* pSource, size_t n); </font></td>
  38. </tr>
  39. <tr>
  40. <td>Stristr</td>
  41. <td>Case insensitive version of strstr (find string within string)</td>
  42. <td><font size="-1">char_t* Stristr(const char_t* pString, const char_t* pSubString);</font></td>
  43. </tr>
  44. <tr>
  45. <td>FtoaEnglish</td>
  46. <td>
  47. <p>Float to ascii; always use English numeric format, regardless of the current locale.</p>
  48. </td>
  49. <td><font size="-1">char_t* FtoaEnglish(double dValue, char_t* pResult, int nInputLength, int nPrecision, bool bExponentEnabled); </font></td>
  50. </tr>
  51. <tr>
  52. <td>AtofEnglish</td>
  53. <td>Ascii to float; always use English numeric format, regardless of the current locale.</td>
  54. <td><font size="-1">double AtofEnglish(const char_t* pString); </font></td>
  55. </tr>
  56. <tr>
  57. <td> StrtodEnglish</td>
  58. <td>Same as strtod, but always use English numeric format, regardless of the current locale.</td>
  59. <td><font size="-1">double StrtodEnglish(const char_t* pString, char_t** ppStringEnd);</font></td>
  60. </tr>
  61. <tr>
  62. <td>Memset16</td>
  63. <td>Sets 16 bit values in memory (as opposed to memset's 8 bit values)</td>
  64. <td><font size="-1">uint16_t* Memset16(void* pDestination, uint16_t c, size_t count); </font></td>
  65. </tr>
  66. <tr>
  67. <td>Memset32</td>
  68. <td>Sets 32 bit values in memory (as opposed to memset's 8 bit values)</td>
  69. <td><font size="-1"> uint32_t* Memset32(void* pDestination, uint32_t c, size_t count);</font></td>
  70. </tr>
  71. <tr>
  72. <td>Memset64</td>
  73. <td>Sets 64 bit values in memory (as opposed to memset's 8 bit values)</td>
  74. <td><font size="-1">uint64_t* Memset64(void* pDestination, uint64_t c, size_t count);</font></td>
  75. </tr>
  76. <tr>
  77. <td>MemsetN</td>
  78. <td>Sets arbitrarily sized values in memory.</td>
  79. <td><font size="-1">void* MemsetN (void* pDestination, const void* pSource, size_t sourceBytes, size_t count); </font></td>
  80. </tr>
  81. <tr>
  82. <td>EcvtBuf</td>
  83. <td>Base function for converting a float to a %e string.</td>
  84. <td>
  85. <p><font size="-1">char_t* EcvtBuf(double dValue, int nDigitCount, int* decimalPos, int* sign, char_t* buffer); </font></p>
  86. </td>
  87. </tr>
  88. <tr>
  89. <td>FcvtBuf</td>
  90. <td>Base function for converting a float to a %f string.</td>
  91. <td><font size="-1">char_t* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* decimalPos, int* sign, char_t* buffer); </font></td>
  92. </tr>
  93. </table>
  94. <p>&nbsp;</p>
  95. <h2>Example usage </h2>
  96. <p>We provide a random smattering of example code here.</p>
  97. <pre class="code-example">char16_t buffer[32] = L"hello ";
  98. Strcat16(buffer, L"world");
  99. </pre>
  100. <p>Strlcat:</p>
  101. <pre class="code-example">char buffer[32];
  102. Strlcpy8(buffer, "Hello ", sizeof(buffer));
  103. Strlcat8(buffer, "world", sizeof(buffer));
  104. </pre>
  105. <p>U64toa:</p>
  106. <pre class="code-example">char buffer[32];
  107. U64toa8(UINT64_C(12345678901234567890), buffer, 16);
  108. </pre>
  109. <p>AtoI32:</p>
  110. <pre class="code-example">int32_t x = AtoI328(&quot;1234567890&quot;);
  111. </pre>
  112. <p>StrtodEnglish:</p>
  113. <pre class="code-example">const char16_t* pString = L"12345.678 123.456 1.23456";
  114. while(*pString)
  115. {
  116. double value = StrtodEnglish16(pString, &pString);
  117. printf("Field = %f\n, value);
  118. }
  119. </pre>
  120. <p>Memset16:</p>
  121. <pre class="code-example">uint16_t buffer[50];
  122. Memset16(buffer, 0x1234, 50);
  123. </pre>
  124. <h2>Interface</h2>
  125. <p>In each of the functions below, there is an char8_t and char16_t version. The actual function that EACRT implements is one with an 8 or 16 appended to the function names listed below. Thus below we have <span class="code-example-span">Strcat(char_t*, char_t*)</span>, and thus EACRT presents <span class="code-example-span">Strcat8(char8_t*, char8_t*)</span> and <span class="code-example-span">Strcat16(char16_t*, char16_t*)</span>.</p>
  126. <p>See EACRT.h for per-function documentation.</p>
  127. <pre class="code-example">char_t* Strcat(char_t* pDestination, const char_t* pSource);
  128. char_t* Strncat(char_t* pDestination, const char_t* pSource, size_t n);
  129. char_t* Strlcat(char_t* pDestination, const char_t* pSource, size_t n);
  130. char_t* Strcpy(char_t* pDestination, const char_t* pSource);
  131. char_t* Strncpy(char_t* pDestination, const char_t* pSource, size_t n);
  132. char_t* Strlcpy(char_t* pDestination, const char_t* pSource, size_t n);
  133. size_t Strlen(const char_t* pString);
  134. size_t Strxfrm(char_t* pDest, const char_t* pSource, size_t n);
  135. char_t* Strdup(const char_t* pString);
  136. int Isalnum(char_t c);
  137. int Isalpha(char_t c);
  138. int Isdigit(char_t c);
  139. int Isxdigit(char_t c);
  140. int Isgraph(char_t c);
  141. int Islower(char_t c);
  142. int Isprint(char_t c);
  143. int Ispunct(char_t c);
  144. int Isspace(char_t c);
  145. int Iscntrl(char_t c);
  146. int Isascii(char_t c);
  147. int Toupper(char_t c);
  148. int Tolower(char_t c);
  149. char_t* Strlwr(char_t* pString);
  150. char_t* Strupr(char_t* pString);
  151. char_t* Strchr(const char_t* pString, char_t c);
  152. size_t Strcspn(const char_t* pString1, const char_t* pString2);
  153. char_t* Strpbrk(const char_t* pString1, const char_t* pString2);
  154. char_t* Strrchr(const char_t* pString, char_t c);
  155. size_t Strspn(const char_t* pString, const char_t* pSubString);
  156. char_t* Strstr(const char_t* pString, const char_t* pSubString);
  157. char_t* Stristr(const char_t* pString, const char_t* pSubString);
  158. char_t* Strtok(char_t* pString, const char_t* pTokens, char_t** pContext);
  159. char_t* Strset(char_t* pString, char_t c);
  160. char_t* Strnset(char_t* pString, char_t c, size_t n);
  161. char_t* Strrev(char_t* pString);
  162. int Strcmp(const char_t* pString1, const char_t* pString2);
  163. int Strncmp(const char_t* pString1, const char_t* pString2, size_t n);
  164. int Stricmp(const char_t* pString1, const char_t* pString2);
  165. int Strnicmp(const char_t* pString1, const char_t* pString2, size_t n);
  166. int Strcoll(const char_t* pString1, const char_t* pString2);
  167. int Strncoll(const char_t* pString1, const char_t* pString2, size_t n);
  168. int Stricoll(const char_t* pString1, const char_t* pString2);
  169. int Strnicoll(const char_t* pString1, const char_t* pString1, size_t n);
  170. char_t* EcvtBuf(double dValue, int nDigitCount, int* decimalPos, int* sign, char_t* buffer);
  171. char_t* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* decimalPos, int* sign, char_t* buffer);
  172. char_t* I32toa(int32_t nValue, char_t* pResult, int nBase);
  173. char_t* U32toa(uint32_t nValue, char_t* pResult, int nBase);
  174. char_t* I64toa(int64_t nValue, char_t* pBuffer, int nBase);
  175. char_t* U64toa(uint64_t nValue, char_t* pBuffer, int nBase);
  176. double Strtod(const char_t* pString, char_t** ppStringEnd);
  177. double StrtodEnglish(const char_t* pString, char_t** ppStringEnd);
  178. int64_t StrtoI64(const char_t* pString, char_t** ppStringEnd, int nBase);
  179. uint64_t StrtoU64(const char_t* pString, char_t** ppStringEnd, int nBase);
  180. int32_t StrtoI32(const char_t* pString, char_t** ppStringEnd, int nBase);
  181. uint32_t StrtoU32(const char_t* pString, char_t** ppStringEnd, int nBase);
  182. int32_t AtoI32(const char_t* pString);
  183. uint32_t AtoU32(const char_t* pString);
  184. int64_t AtoI64(const char_t* pString);
  185. uint64_t AtoU64(const char_t* pString);
  186. double Atof(const char_t* pString);
  187. double AtofEnglish(const char_t* pString);
  188. char_t* Ftoa(double dValue, char_t* pResult, int nInputLength, int nPrecision, bool bExponentEnabled);
  189. char_t* FtoaEnglish(double dValue, char_t* pResult, int nInputLength, int nPrecision, bool bExponentEnabled);
  190. uint8_t* Memset8 (void* pDestination, uint8_t c, size_t count);
  191. uint16_t* Memset16(void* pDestination, uint16_t c, size_t count);
  192. uint32_t* Memset32(void* pDestination, uint32_t c, size_t count);
  193. uint64_t* Memset64(void* pDestination, uint64_t c, size_t count);
  194. void* MemsetN (void* pDestination, const void* pSource, size_t sourceBytes, size_t count);
  195. const char_t* Memchr(const char_t* pString, char_t c, size_t n);
  196. int Memcmp(const char_t* pString1, const char_t* pString2, size_t n);
  197. char_t* Memcpy(char_t* pDestination, const char_t* pSource, size_t n);
  198. char_t* Memmove(char_t* pDestination, const char_t* pSource, size_t n);
  199. char_t* Memset(char_t* pString, char_t c, size_t n);
  200. </pre>
  201. <hr>
  202. <p>&nbsp;</p>
  203. <p>&nbsp;</p>
  204. <p>&nbsp;</p>
  205. <p>&nbsp;</p>
  206. <p>&nbsp;</p>
  207. <p>&nbsp;</p>
  208. <p>&nbsp;</p>
  209. <p>&nbsp;</p>
  210. <p>&nbsp;</p>
  211. <p>&nbsp;</p>
  212. <p>&nbsp;</p>
  213. <p>&nbsp;</p>
  214. <p>&nbsp;</p>
  215. <p> </p>
  216. </body></html>