EAScanf.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type"
  5. content="text/html; charset=ISO-8859-1">
  6. <title>EAScanf</title>
  7. <link type="text/css" rel="stylesheet"
  8. href="UTFDoc.css">
  9. <meta name="author" content="Paul Pedriana">
  10. </head>
  11. <body style="background-color: rgb(255, 255, 255);">
  12. <h1>EAScanf</h1>
  13. <h2>Introduction</h2>
  14. <p>EAScanf provides a portable
  15. version of the C scanf family of functions which improves on
  16. the C family in the following ways:</p>
  17. <ul>
  18. <li>Behaves identically on all
  19. platforms</li>
  20. <li>Provides the full gamut of
  21. scanf functions, including vsscanf</li>
  22. <li>Is more efficient</li>
  23. <li>Never allocates memory</li>
  24. <li>Provides both 8 and 16 bit
  25. versions for all platforms</li>
  26. <li>Provides&nbsp;useful
  27. extended functionality</li>
  28. <li>Complies with the C99
  29. standard (except for the %a format, as of this writing)</li>
  30. <li>Is readable enough to be
  31. traced/debugged by non-experts</li>
  32. <li>Is savvy to UTF8 Unicode</li>
  33. </ul>
  34. <p>The primary disadvantages of
  35. EAScanf are:</p>
  36. <ul>
  37. <li>It doesn't use
  38. locale-specific formatting</li>
  39. <li>It isn't part of the C/C++
  40. standard library</li>
  41. </ul>
  42. <p>EAScanf doesn't attempt to
  43. solve the locale formatting problem because users really are better off
  44. using serious locale libraries for such things rather than using the
  45. meager support provided by the C standard library. The EALocale library
  46. attempts to provide such functionality.</p>
  47. <p>EAScanf provides the
  48. following functions in 8 and 16 bit versions:
  49. </p>
  50. <pre><span class="code-example">int Cscanf(ReadFunction8 pReadFunction8, void* pContext, const char8_t* pFormat, ...);
  51. int Fscanf(FILE* pFile, const char8_t* pFormat, ...);
  52. int Scanf(const char8_t* pFormat, ...);
  53. int Sscanf(const char8_t* pTextBuffer, const char8_t* pFormat, ...);
  54. int Cscanf(ReadFunction16 pReadFunction16, void* pContext, const char16_t* pFormat, ...);
  55. int Fscanf(FILE* pFile, const char16_t* pFormat, ...);
  56. int Scanf(const char16_t* pFormat, ...);
  57. int Sscanf(const char16_t* pTextBuffer, const char16_t* pFormat, ...);
  58. int Vcscanf(ReadFunction8 pReadFunction8, void* pContext, const char8_t* pFormat, va_list arguments);
  59. int Vfscanf(FILE* pFile, const char8_t* pFormat, va_list arguments);
  60. int Vscanf(const char8_t* pFormat, va_list arguments);
  61. int Vsscanf(const char8_t* pTextBuffer, const char8_t* pFormat, va_list arguments);
  62. int Vcscanf(ReadFunction16 pReadFunction16, void* pContext, const char16_t* pFormat, va_list arguments);
  63. int Vfscanf(FILE* pFile, const char16_t* pFormat, va_list arguments);
  64. int Vscanf(const char16_t* pFormat, va_list arguments);
  65. int Vsscanf(const char16_t* pTextBuffer, const char16_t* pFormat, va_list arguments);</span></pre>
  66. <blockquote> </blockquote>
  67. <h2>Extended Functionality</h2>
  68. <p> EAPrintf provides extended
  69. format functionality not found in the C99 standard but which is useful
  70. nevertheless:</p>
  71. <table style="text-align: left; width: 100%;" border="1" cellpadding="2"
  72. cellspacing="2">
  73. <tbody>
  74. <tr style="font-weight: bold;">
  75. <td>Format</td>
  76. <td>Description</td>
  77. <td>Example</td>
  78. <td>Example output</td>
  79. </tr>
  80. <tr style="font-weight: bold;">
  81. <td><span style="font-weight: normal;">b</span></td>
  82. <td style="font-weight: normal;">Binary
  83. output field type (joins d, i, x, o, etc.).</td>
  84. <td><span style="font-weight: normal;">sscanf(&quot;11111111&quot;, "%b", &amp;integer);</span></td>
  85. <td><span style="font-weight: normal;">integer == 0xff </span></td>
  86. </tr>
  87. <tr>
  88. <td>I8</td>
  89. <td>8 bit integer field
  90. modifier.</td>
  91. <td><span style="font-weight: normal;">sscanf</span>(&quot;0xff&quot;, "%I8d"<span style="font-weight: normal;">, &amp;int8</span>);</td>
  92. <td><span style="font-weight: normal;"><span style="font-weight: normal;">int8</span> == <span style="font-weight: normal;">0xff </span></span></td>
  93. </tr>
  94. <tr>
  95. <td>I16</td>
  96. <td>16 bit integer field
  97. modifier.</td>
  98. <td><span style="font-weight: normal;">sscanf</span>(&quot;0xffff&quot;, "%I16u"<span style="font-weight: normal;">, &amp;uint16</span>);</td>
  99. <td><span style="font-weight: normal;"><span style="font-weight: normal;">uint16</span> == <span style="font-weight: normal;">0xffff</span></span></td>
  100. </tr>
  101. <tr>
  102. <td>I32</td>
  103. <td>32 bit integer field
  104. modifier.</td>
  105. <td><span style="font-weight: normal;">sscanf</span>(&quot;0xffffffff&quot;, "%I32d"<span style="font-weight: normal;">, &amp;int32</span>);</td>
  106. <td><span style="font-weight: normal;"><span style="font-weight: normal;">int32</span> == <span style="font-weight: normal;">0xffff</span></span>ffff</td>
  107. </tr>
  108. <tr>
  109. <td>I64</td>
  110. <td>64 bit integer field
  111. modifier.</td>
  112. <td><span style="font-weight: normal;">sscanf</span>(&quot;0xffffffffffffffff&quot;, "%I64u"<span style="font-weight: normal;">, &amp;int64</span>);</td>
  113. <td><span style="font-weight: normal;">int64</span> == -1 </td>
  114. </tr>
  115. <tr>
  116. <td>I128</td>
  117. <td>128 bit integer field
  118. modifier.</td>
  119. <td><span style="font-weight: normal;">sscanf</span>(&quot;0xffffffffffffffffffffffffffffffff&quot;, "%I128d"<span style="font-weight: normal;">, &amp;int128</span>);</td>
  120. <td><span style="font-weight: normal;">int128</span> = -1</td>
  121. </tr>
  122. </tbody>
  123. </table>
  124. <h2>Example usage</h2>
  125. <p>To do.<br>
  126. </p>
  127. <hr>
  128. <p>&nbsp;</p>
  129. <p>&nbsp;</p>
  130. <p>&nbsp;</p>
  131. <p>&nbsp;</p>
  132. <p>&nbsp;</p>
  133. <p>&nbsp;</p>
  134. <p>&nbsp;</p>
  135. <p>&nbsp;</p>
  136. <p>&nbsp;</p>
  137. <p>&nbsp;</p>
  138. <p>&nbsp;</p>
  139. <p>&nbsp;</p>
  140. <p>&nbsp;</p>
  141. <p> </p>
  142. </body>
  143. </html>