utf-8_8c.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.17"/>
  7. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  8. <title>MQTT C Client Libraries Internals: utf-8.c File Reference</title>
  9. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  13. <script type="text/javascript" src="search/searchdata.js"></script>
  14. <script type="text/javascript" src="search/search.js"></script>
  15. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  19. <div id="titlearea">
  20. <table cellspacing="0" cellpadding="0">
  21. <tbody>
  22. <tr style="height: 56px;">
  23. <td id="projectlogo"><img alt="Logo" src="pahologo.png"/></td>
  24. <td id="projectalign" style="padding-left: 0.5em;">
  25. <div id="projectname">MQTT C Client Libraries Internals
  26. </div>
  27. </td>
  28. </tr>
  29. </tbody>
  30. </table>
  31. </div>
  32. <!-- end header part -->
  33. <!-- Generated by Doxygen 1.8.17 -->
  34. <script type="text/javascript">
  35. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  36. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  37. /* @license-end */
  38. </script>
  39. <script type="text/javascript" src="menudata.js"></script>
  40. <script type="text/javascript" src="menu.js"></script>
  41. <script type="text/javascript">
  42. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  43. $(function() {
  44. initMenu('',true,false,'search.php','Search');
  45. $(document).ready(function() { init_search(); });
  46. });
  47. /* @license-end */</script>
  48. <div id="main-nav"></div>
  49. <!-- window showing the filter options -->
  50. <div id="MSearchSelectWindow"
  51. onmouseover="return searchBox.OnSearchSelectShow()"
  52. onmouseout="return searchBox.OnSearchSelectHide()"
  53. onkeydown="return searchBox.OnSearchSelectKey(event)">
  54. </div>
  55. <!-- iframe showing the search results (closed by default) -->
  56. <div id="MSearchResultsWindow">
  57. <iframe src="javascript:void(0)" frameborder="0"
  58. name="MSearchResults" id="MSearchResults">
  59. </iframe>
  60. </div>
  61. </div><!-- top -->
  62. <div class="header">
  63. <div class="summary">
  64. <a href="#define-members">Macros</a> &#124;
  65. <a href="#func-members">Functions</a> &#124;
  66. <a href="#var-members">Variables</a> </div>
  67. <div class="headertitle">
  68. <div class="title">utf-8.c File Reference</div> </div>
  69. </div><!--header-->
  70. <div class="contents">
  71. <p>Functions for checking that strings contain UTF-8 characters only.
  72. <a href="#details">More...</a></p>
  73. <div class="textblock"><code>#include &quot;utf-8.h&quot;</code><br />
  74. <code>#include &lt;stdlib.h&gt;</code><br />
  75. <code>#include &lt;string.h&gt;</code><br />
  76. <code>#include &quot;StackTrace.h&quot;</code><br />
  77. </div><div class="textblock"><div class="dynheader">
  78. Include dependency graph for utf-8.c:</div>
  79. <div class="dyncontent">
  80. <div class="center"><img src="utf-8_8c__incl.png" border="0" usemap="#utf-8_8c" alt=""/></div>
  81. <map name="utf-8_8c" id="utf-8_8c">
  82. <area shape="rect" title="Functions for checking that strings contain UTF&#45;8 characters only." alt="" coords="51,5,110,32"/>
  83. <area shape="rect" title=" " alt="" coords="5,80,68,107"/>
  84. <area shape="rect" title=" " alt="" coords="93,80,157,107"/>
  85. </map>
  86. </div>
  87. </div><table class="memberdecls">
  88. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
  89. Macros</h2></td></tr>
  90. <tr class="memitem:a25f003de16c08a4888b69f619d70f427"><td class="memItemLeft" align="right" valign="top"><a id="a25f003de16c08a4888b69f619d70f427"></a>
  91. #define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="utf-8_8c.html#a25f003de16c08a4888b69f619d70f427">ARRAY_SIZE</a>(a)&#160;&#160;&#160;(sizeof(a) / sizeof(a[0]))</td></tr>
  92. <tr class="memdesc:a25f003de16c08a4888b69f619d70f427"><td class="mdescLeft">&#160;</td><td class="mdescRight">Macro to determine the number of elements in a single-dimension array. <br /></td></tr>
  93. <tr class="separator:a25f003de16c08a4888b69f619d70f427"><td class="memSeparator" colspan="2">&#160;</td></tr>
  94. </table><table class="memberdecls">
  95. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
  96. Functions</h2></td></tr>
  97. <tr class="memitem:a9727caa7417e6bed8cfad4121a22628d"><td class="memItemLeft" align="right" valign="top">static const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="utf-8_8c.html#a9727caa7417e6bed8cfad4121a22628d">UTF8_char_validate</a> (int <a class="el" href="utf-8_8c.html#afed088663f8704004425cdae2120b9b3">len</a>, const char *data)</td></tr>
  98. <tr class="memdesc:a9727caa7417e6bed8cfad4121a22628d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Validate a single UTF-8 character. <a href="utf-8_8c.html#a9727caa7417e6bed8cfad4121a22628d">More...</a><br /></td></tr>
  99. <tr class="separator:a9727caa7417e6bed8cfad4121a22628d"><td class="memSeparator" colspan="2">&#160;</td></tr>
  100. <tr class="memitem:ad2012627fca4b4bdd9f67bde49b0d1cb"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="utf-8_8c.html#ad2012627fca4b4bdd9f67bde49b0d1cb">UTF8_validate</a> (int <a class="el" href="utf-8_8c.html#afed088663f8704004425cdae2120b9b3">len</a>, const char *data)</td></tr>
  101. <tr class="memdesc:ad2012627fca4b4bdd9f67bde49b0d1cb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Validate a length-delimited string has only UTF-8 characters. <a href="utf-8_8c.html#ad2012627fca4b4bdd9f67bde49b0d1cb">More...</a><br /></td></tr>
  102. <tr class="separator:ad2012627fca4b4bdd9f67bde49b0d1cb"><td class="memSeparator" colspan="2">&#160;</td></tr>
  103. <tr class="memitem:a4f3cf77538d867bb5b421bcb687dccdf"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="utf-8_8c.html#a4f3cf77538d867bb5b421bcb687dccdf">UTF8_validateString</a> (const char *string)</td></tr>
  104. <tr class="memdesc:a4f3cf77538d867bb5b421bcb687dccdf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Validate a null-terminated string has only UTF-8 characters. <a href="utf-8_8c.html#a4f3cf77538d867bb5b421bcb687dccdf">More...</a><br /></td></tr>
  105. <tr class="separator:a4f3cf77538d867bb5b421bcb687dccdf"><td class="memSeparator" colspan="2">&#160;</td></tr>
  106. </table><table class="memberdecls">
  107. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
  108. Variables</h2></td></tr>
  109. <tr class="memitem:a03bdcd5f0e47e86161d8f8a6e6d2ed1d"><td class="memItemLeft" >struct {</td></tr>
  110. <tr class="memitem:a2b3508920af3b46c4ea33ea0e6a58cfa"><td class="memItemLeft" >
  111. &#160;&#160;&#160;int&#160;&#160;&#160;<a class="el" href="utf-8_8c.html#afed088663f8704004425cdae2120b9b3">len</a></td></tr>
  112. <tr class="memdesc:a2b3508920af3b46c4ea33ea0e6a58cfa"><td class="mdescLeft">&#160;</td><td class="mdescRight">number of elements in the following array (1 to 4) <br /></td></tr>
  113. <tr class="separator:a2b3508920af3b46c4ea33ea0e6a58cfa"><td class="memSeparator" colspan="2">&#160;</td></tr>
  114. <tr class="memitem:a2b165add953f0274aa17034848338b86"><td class="memItemLeft" >
  115. &#160;&#160;&#160;struct {</td></tr>
  116. <tr class="memitem:aff90f712bbe02f22eb3681538c7f825f"><td class="memItemLeft" >
  117. &#160;&#160;&#160;&#160;&#160;&#160;char&#160;&#160;&#160;<a class="el" href="utf-8_8c.html#a17ae1b83727db4230c8df98b4ee953fc">lower</a></td></tr>
  118. <tr class="memdesc:aff90f712bbe02f22eb3681538c7f825f"><td class="mdescLeft">&#160;</td><td class="mdescRight">lower limit of valid range <br /></td></tr>
  119. <tr class="separator:aff90f712bbe02f22eb3681538c7f825f"><td class="memSeparator" colspan="2">&#160;</td></tr>
  120. <tr class="memitem:a0cc1558bceab574eff8f0455583dc45e"><td class="memItemLeft" >
  121. &#160;&#160;&#160;&#160;&#160;&#160;char&#160;&#160;&#160;<a class="el" href="utf-8_8c.html#a716463de5d02ad40678f2376abcdd90a">upper</a></td></tr>
  122. <tr class="memdesc:a0cc1558bceab574eff8f0455583dc45e"><td class="mdescLeft">&#160;</td><td class="mdescRight">upper limit of valid range <br /></td></tr>
  123. <tr class="separator:a0cc1558bceab574eff8f0455583dc45e"><td class="memSeparator" colspan="2">&#160;</td></tr>
  124. <tr class="memitem:a2b165add953f0274aa17034848338b86"><td class="memItemLeft" valign="top">&#160;&#160;&#160;}&#160;&#160;&#160;<a class="el" href="utf-8_8c.html#abf4b7aec66b165e9a0a8e3a4ad69f863">bytes</a> [4]</td></tr>
  125. <tr class="memdesc:a2b165add953f0274aa17034848338b86"><td class="mdescLeft">&#160;</td><td class="mdescRight">up to 4 bytes can be used per character <br /></td></tr>
  126. <tr class="separator:a2b165add953f0274aa17034848338b86"><td class="memSeparator" colspan="2">&#160;</td></tr>
  127. <tr class="memitem:a03bdcd5f0e47e86161d8f8a6e6d2ed1d"><td class="memItemLeft" valign="top">}&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="utf-8_8c.html#a03bdcd5f0e47e86161d8f8a6e6d2ed1d">valid_ranges</a> []</td></tr>
  128. <tr class="memdesc:a03bdcd5f0e47e86161d8f8a6e6d2ed1d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Structure to hold the valid ranges of UTF-8 characters, for each byte up to 4. <a href="utf-8_8c.html#a03bdcd5f0e47e86161d8f8a6e6d2ed1d">More...</a><br /></td></tr>
  129. <tr class="separator:a03bdcd5f0e47e86161d8f8a6e6d2ed1d"><td class="memSeparator" colspan="2">&#160;</td></tr>
  130. </table>
  131. <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
  132. <div class="textblock"><p>Functions for checking that strings contain UTF-8 characters only. </p>
  133. <p>See page 104 of the Unicode Standard 5.0 for the list of well formed UTF-8 byte sequences. </p>
  134. </div><h2 class="groupheader">Function Documentation</h2>
  135. <a id="a9727caa7417e6bed8cfad4121a22628d"></a>
  136. <h2 class="memtitle"><span class="permalink"><a href="#a9727caa7417e6bed8cfad4121a22628d">&#9670;&nbsp;</a></span>UTF8_char_validate()</h2>
  137. <div class="memitem">
  138. <div class="memproto">
  139. <table class="mlabels">
  140. <tr>
  141. <td class="mlabels-left">
  142. <table class="memname">
  143. <tr>
  144. <td class="memname">static const char * UTF8_char_validate </td>
  145. <td>(</td>
  146. <td class="paramtype">int&#160;</td>
  147. <td class="paramname"><em>len</em>, </td>
  148. </tr>
  149. <tr>
  150. <td class="paramkey"></td>
  151. <td></td>
  152. <td class="paramtype">const char *&#160;</td>
  153. <td class="paramname"><em>data</em>&#160;</td>
  154. </tr>
  155. <tr>
  156. <td></td>
  157. <td>)</td>
  158. <td></td><td></td>
  159. </tr>
  160. </table>
  161. </td>
  162. <td class="mlabels-right">
  163. <span class="mlabels"><span class="mlabel">static</span></span> </td>
  164. </tr>
  165. </table>
  166. </div><div class="memdoc">
  167. <p>Validate a single UTF-8 character. </p>
  168. <dl class="params"><dt>Parameters</dt><dd>
  169. <table class="params">
  170. <tr><td class="paramname">len</td><td>the length of the string in "data" </td></tr>
  171. <tr><td class="paramname">data</td><td>the bytes to check for a valid UTF-8 char </td></tr>
  172. </table>
  173. </dd>
  174. </dl>
  175. <dl class="section return"><dt>Returns</dt><dd>pointer to the start of the next UTF-8 character in "data" </dd></dl>
  176. </div>
  177. </div>
  178. <a id="ad2012627fca4b4bdd9f67bde49b0d1cb"></a>
  179. <h2 class="memtitle"><span class="permalink"><a href="#ad2012627fca4b4bdd9f67bde49b0d1cb">&#9670;&nbsp;</a></span>UTF8_validate()</h2>
  180. <div class="memitem">
  181. <div class="memproto">
  182. <table class="memname">
  183. <tr>
  184. <td class="memname">int UTF8_validate </td>
  185. <td>(</td>
  186. <td class="paramtype">int&#160;</td>
  187. <td class="paramname"><em>len</em>, </td>
  188. </tr>
  189. <tr>
  190. <td class="paramkey"></td>
  191. <td></td>
  192. <td class="paramtype">const char *&#160;</td>
  193. <td class="paramname"><em>data</em>&#160;</td>
  194. </tr>
  195. <tr>
  196. <td></td>
  197. <td>)</td>
  198. <td></td><td></td>
  199. </tr>
  200. </table>
  201. </div><div class="memdoc">
  202. <p>Validate a length-delimited string has only UTF-8 characters. </p>
  203. <dl class="params"><dt>Parameters</dt><dd>
  204. <table class="params">
  205. <tr><td class="paramname">len</td><td>the length of the string in "data" </td></tr>
  206. <tr><td class="paramname">data</td><td>the bytes to check for valid UTF-8 characters </td></tr>
  207. </table>
  208. </dd>
  209. </dl>
  210. <dl class="section return"><dt>Returns</dt><dd>1 (true) if the string has only UTF-8 characters, 0 (false) otherwise </dd></dl>
  211. <div class="dynheader">
  212. Here is the call graph for this function:</div>
  213. <div class="dyncontent">
  214. <div class="center"><img src="utf-8_8c_ad2012627fca4b4bdd9f67bde49b0d1cb_cgraph.png" border="0" usemap="#utf-8_8c_ad2012627fca4b4bdd9f67bde49b0d1cb_cgraph" alt=""/></div>
  215. <map name="utf-8_8c_ad2012627fca4b4bdd9f67bde49b0d1cb_cgraph" id="utf-8_8c_ad2012627fca4b4bdd9f67bde49b0d1cb_cgraph">
  216. <area shape="rect" title="Validate a length&#45;delimited string has only UTF&#45;8 characters." alt="" coords="5,5,112,32"/>
  217. <area shape="rect" href="utf-8_8c.html#a9727caa7417e6bed8cfad4121a22628d" title="Validate a single UTF&#45;8 character." alt="" coords="160,5,299,32"/>
  218. </map>
  219. </div>
  220. </div>
  221. </div>
  222. <a id="a4f3cf77538d867bb5b421bcb687dccdf"></a>
  223. <h2 class="memtitle"><span class="permalink"><a href="#a4f3cf77538d867bb5b421bcb687dccdf">&#9670;&nbsp;</a></span>UTF8_validateString()</h2>
  224. <div class="memitem">
  225. <div class="memproto">
  226. <table class="memname">
  227. <tr>
  228. <td class="memname">int UTF8_validateString </td>
  229. <td>(</td>
  230. <td class="paramtype">const char *&#160;</td>
  231. <td class="paramname"><em>string</em></td><td>)</td>
  232. <td></td>
  233. </tr>
  234. </table>
  235. </div><div class="memdoc">
  236. <p>Validate a null-terminated string has only UTF-8 characters. </p>
  237. <dl class="params"><dt>Parameters</dt><dd>
  238. <table class="params">
  239. <tr><td class="paramname">string</td><td>the string to check for valid UTF-8 characters </td></tr>
  240. </table>
  241. </dd>
  242. </dl>
  243. <dl class="section return"><dt>Returns</dt><dd>1 (true) if the string has only UTF-8 characters, 0 (false) otherwise </dd></dl>
  244. <div class="dynheader">
  245. Here is the call graph for this function:</div>
  246. <div class="dyncontent">
  247. <div class="center"><img src="utf-8_8c_a4f3cf77538d867bb5b421bcb687dccdf_cgraph.png" border="0" usemap="#utf-8_8c_a4f3cf77538d867bb5b421bcb687dccdf_cgraph" alt=""/></div>
  248. <map name="utf-8_8c_a4f3cf77538d867bb5b421bcb687dccdf_cgraph" id="utf-8_8c_a4f3cf77538d867bb5b421bcb687dccdf_cgraph">
  249. <area shape="rect" title="Validate a null&#45;terminated string has only UTF&#45;8 characters." alt="" coords="5,5,147,32"/>
  250. <area shape="rect" href="utf-8_8c.html#ad2012627fca4b4bdd9f67bde49b0d1cb" title="Validate a length&#45;delimited string has only UTF&#45;8 characters." alt="" coords="195,5,301,32"/>
  251. <area shape="rect" href="utf-8_8c.html#a9727caa7417e6bed8cfad4121a22628d" title="Validate a single UTF&#45;8 character." alt="" coords="349,5,488,32"/>
  252. </map>
  253. </div>
  254. </div>
  255. </div>
  256. <h2 class="groupheader">Variable Documentation</h2>
  257. <a id="a03bdcd5f0e47e86161d8f8a6e6d2ed1d"></a>
  258. <h2 class="memtitle"><span class="permalink"><a href="#a03bdcd5f0e47e86161d8f8a6e6d2ed1d">&#9670;&nbsp;</a></span>valid_ranges</h2>
  259. <div class="memitem">
  260. <div class="memproto">
  261. <table class="memname">
  262. <tr>
  263. <td class="memname">struct { ... } valid_ranges[]</td>
  264. </tr>
  265. </table>
  266. </div><div class="memdoc">
  267. <b>Initial value:</b><div class="fragment"><div class="line">=</div>
  268. <div class="line">{</div>
  269. <div class="line"> {1, { {00, 0x7F} } },</div>
  270. <div class="line"> {2, { {0xC2, 0xDF}, {0x80, 0xBF} } },</div>
  271. <div class="line"> {3, { {0xE0, 0xE0}, {0xA0, 0xBF}, {0x80, 0xBF} } },</div>
  272. <div class="line"> {3, { {0xE1, 0xEC}, {0x80, 0xBF}, {0x80, 0xBF} } },</div>
  273. <div class="line"> {3, { {0xED, 0xED}, {0x80, 0x9F}, {0x80, 0xBF} } },</div>
  274. <div class="line"> {3, { {0xEE, 0xEF}, {0x80, 0xBF}, {0x80, 0xBF} } },</div>
  275. <div class="line"> {4, { {0xF0, 0xF0}, {0x90, 0xBF}, {0x80, 0xBF}, {0x80, 0xBF} } },</div>
  276. <div class="line"> {4, { {0xF1, 0xF3}, {0x80, 0xBF}, {0x80, 0xBF}, {0x80, 0xBF} } },</div>
  277. <div class="line"> {4, { {0xF4, 0xF4}, {0x80, 0x8F}, {0x80, 0xBF}, {0x80, 0xBF} } },</div>
  278. <div class="line">}</div>
  279. </div><!-- fragment -->
  280. <p>Structure to hold the valid ranges of UTF-8 characters, for each byte up to 4. </p>
  281. </div>
  282. </div>
  283. </div><!-- contents -->
  284. <!-- start footer part -->
  285. <hr class="footer"/><address class="footer"><small>
  286. Generated on Thu Sep 29 2022 11:34:46 for MQTT C Client Libraries Internals by &#160;<a href="http://www.doxygen.org/index.html">
  287. <img class="footer" src="doxygen.png" alt="doxygen"/>
  288. </a> 1.8.17
  289. </small></address>
  290. </body>
  291. </html>