1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>xmlstring: set of routines to process strings</title> 5<meta name="generator" content="Libxml2 devhelp stylesheet"> 6<link rel="start" href="index.html" title="libxml2 Reference Manual"> 7<link rel="up" href="general.html" title="API"> 8<link rel="stylesheet" href="style.css" type="text/css"> 9<link rel="chapter" href="general.html" title="API"> 10</head> 11<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 12<table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"> 13<td><a accesskey="p" href="libxml2-xmlschemastypes.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td> 14<td><a accesskey="u" href="general.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td> 15<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td> 16<td><a accesskey="n" href="libxml2-xmlunicode.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td> 17<th width="100%" align="center">libxml2 Reference Manual</th> 18</tr></table> 19<h2><span class="refentrytitle">xmlstring</span></h2> 20<p>xmlstring - set of routines to process strings</p> 21<p>type and interfaces needed for the internal string handling of the library, especially UTF8 processing. </p> 22<p>Author(s): Daniel Veillard </p> 23<div class="refsynopsisdiv"> 24<h2>Synopsis</h2> 25<pre class="synopsis">#define <a href="#BAD_CAST">BAD_CAST</a>; 26typedef unsigned char <a href="#xmlChar">xmlChar</a>; 27<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlCharStrdup">xmlCharStrdup</a> (const char * cur); 28<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlCharStrndup">xmlCharStrndup</a> (const char * cur, <br> int len); 29int <a href="#xmlCheckUTF8">xmlCheckUTF8</a> (const unsigned char * utf); 30int <a href="#xmlGetUTF8Char">xmlGetUTF8Char</a> (const unsigned char * utf, <br> int * len); 31int <a href="#xmlStrEqual">xmlStrEqual</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str1, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str2); 32int <a href="#xmlStrPrintf">xmlStrPrintf</a> (<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * buf, <br> int len, <br> const char * msg, <br> ... ...); 33int <a href="#xmlStrQEqual">xmlStrQEqual</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * pref, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str); 34int <a href="#xmlStrVPrintf">xmlStrVPrintf</a> (<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * buf, <br> int len, <br> const char * msg, <br> va_list ap); 35int <a href="#xmlStrcasecmp">xmlStrcasecmp</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str1, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str2); 36const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlStrcasestr">xmlStrcasestr</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * val); 37<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlStrcat">xmlStrcat</a> (<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * add); 38const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlStrchr">xmlStrchr</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br> <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> val); 39int <a href="#xmlStrcmp">xmlStrcmp</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str1, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str2); 40<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlStrdup">xmlStrdup</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur); 41int <a href="#xmlStrlen">xmlStrlen</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str); 42int <a href="#xmlStrncasecmp">xmlStrncasecmp</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str1, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str2, <br> int len); 43<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlStrncat">xmlStrncat</a> (<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * add, <br> int len); 44<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlStrncatNew">xmlStrncatNew</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str1, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str2, <br> int len); 45int <a href="#xmlStrncmp">xmlStrncmp</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str1, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str2, <br> int len); 46<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlStrndup">xmlStrndup</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br> int len); 47const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlStrstr">xmlStrstr</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * val); 48<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlStrsub">xmlStrsub</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br> int start, <br> int len); 49int <a href="#xmlUTF8Charcmp">xmlUTF8Charcmp</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf1, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf2); 50int <a href="#xmlUTF8Size">xmlUTF8Size</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf); 51int <a href="#xmlUTF8Strlen">xmlUTF8Strlen</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf); 52int <a href="#xmlUTF8Strloc">xmlUTF8Strloc</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utfchar); 53<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlUTF8Strndup">xmlUTF8Strndup</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf, <br> int len); 54const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlUTF8Strpos">xmlUTF8Strpos</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf, <br> int pos); 55int <a href="#xmlUTF8Strsize">xmlUTF8Strsize</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf, <br> int len); 56<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * <a href="#xmlUTF8Strsub">xmlUTF8Strsub</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf, <br> int start, <br> int len); 57</pre> 58</div> 59<div class="refsect1" lang="en"><h2>Description</h2></div> 60<div class="refsect1" lang="en"> 61<h2>Details</h2> 62<div class="refsect2" lang="en"> 63<div class="refsect2" lang="en"> 64<h3> 65<a name="BAD_CAST">Macro </a>BAD_CAST</h3> 66<pre class="programlisting">#define <a href="#BAD_CAST">BAD_CAST</a>; 67</pre> 68<p>Macro to cast a string to an <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * when one know its safe.</p> 69</div> 70<hr> 71<div class="refsect2" lang="en"> 72<h3> 73<a name="xmlChar">Typedef </a>xmlChar</h3> 74<pre class="programlisting">unsigned char xmlChar; 75</pre> 76<p>This is a basic byte in an UTF-8 encoded string. It's unsigned allowing to pinpoint case where char * are assigned to <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * (possibly making serialization back impossible).</p> 77</div> 78<hr> 79<div class="refsect2" lang="en"> 80<h3> 81<a name="xmlCharStrdup"></a>xmlCharStrdup ()</h3> 82<pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlCharStrdup (const char * cur)<br> 83</pre> 84<p>a strdup for char's to xmlChar's</p> 85<div class="variablelist"><table border="0"> 86<col align="left"> 87<tbody> 88<tr> 89<td><span class="term"><i><tt>cur</tt></i>:</span></td> 90<td>the input char *</td> 91</tr> 92<tr> 93<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 94<td>a new <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * or NULL</td> 95</tr> 96</tbody> 97</table></div> 98</div> 99<hr> 100<div class="refsect2" lang="en"> 101<h3> 102<a name="xmlCharStrndup"></a>xmlCharStrndup ()</h3> 103<pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlCharStrndup (const char * cur, <br> int len)<br> 104</pre> 105<p>a strndup for char's to xmlChar's</p> 106<div class="variablelist"><table border="0"> 107<col align="left"> 108<tbody> 109<tr> 110<td><span class="term"><i><tt>cur</tt></i>:</span></td> 111<td>the input char *</td> 112</tr> 113<tr> 114<td><span class="term"><i><tt>len</tt></i>:</span></td> 115<td>the len of @cur</td> 116</tr> 117<tr> 118<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 119<td>a new <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * or NULL</td> 120</tr> 121</tbody> 122</table></div> 123</div> 124<hr> 125<div class="refsect2" lang="en"> 126<h3> 127<a name="xmlCheckUTF8"></a>xmlCheckUTF8 ()</h3> 128<pre class="programlisting">int xmlCheckUTF8 (const unsigned char * utf)<br> 129</pre> 130<p>Checks @utf for being valid UTF-8. @utf is assumed to be null-terminated. This function is not super-strict, as it will allow longer UTF-8 sequences than necessary. Note that Java is capable of producing these sequences if provoked. Also note, this routine checks for the 4-byte maximum size, but does not check for 0x10ffff maximum value.</p> 131<div class="variablelist"><table border="0"> 132<col align="left"> 133<tbody> 134<tr> 135<td><span class="term"><i><tt>utf</tt></i>:</span></td> 136<td>Pointer to putative UTF-8 encoded string.</td> 137</tr> 138<tr> 139<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 140<td>value: true if @utf is valid.</td> 141</tr> 142</tbody> 143</table></div> 144</div> 145<hr> 146<div class="refsect2" lang="en"> 147<h3> 148<a name="xmlGetUTF8Char"></a>xmlGetUTF8Char ()</h3> 149<pre class="programlisting">int xmlGetUTF8Char (const unsigned char * utf, <br> int * len)<br> 150</pre> 151<p>Read the first UTF8 character from @utf</p> 152<div class="variablelist"><table border="0"> 153<col align="left"> 154<tbody> 155<tr> 156<td><span class="term"><i><tt>utf</tt></i>:</span></td> 157<td>a sequence of UTF-8 encoded bytes</td> 158</tr> 159<tr> 160<td><span class="term"><i><tt>len</tt></i>:</span></td> 161<td>a pointer to the minimum number of bytes present in the sequence. This is used to assure the next character is completely contained within the sequence.</td> 162</tr> 163<tr> 164<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 165<td>the char value or -1 in case of error, and sets *len to the actual number of bytes consumed (0 in case of error)</td> 166</tr> 167</tbody> 168</table></div> 169</div> 170<hr> 171<div class="refsect2" lang="en"> 172<h3> 173<a name="xmlStrEqual"></a>xmlStrEqual ()</h3> 174<pre class="programlisting">int xmlStrEqual (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str1, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str2)<br> 175</pre> 176<p>Check if both strings are equal of have same content. Should be a bit more readable and faster than xmlStrcmp()</p> 177<div class="variablelist"><table border="0"> 178<col align="left"> 179<tbody> 180<tr> 181<td><span class="term"><i><tt>str1</tt></i>:</span></td> 182<td>the first <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *</td> 183</tr> 184<tr> 185<td><span class="term"><i><tt>str2</tt></i>:</span></td> 186<td>the second <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *</td> 187</tr> 188<tr> 189<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 190<td>1 if they are equal, 0 if they are different</td> 191</tr> 192</tbody> 193</table></div> 194</div> 195<hr> 196<div class="refsect2" lang="en"> 197<h3> 198<a name="xmlStrPrintf"></a>xmlStrPrintf ()</h3> 199<pre class="programlisting">int xmlStrPrintf (<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * buf, <br> int len, <br> const char * msg, <br> ... ...)<br> 200</pre> 201<p>Formats @msg and places result into @buf.</p> 202<div class="variablelist"><table border="0"> 203<col align="left"> 204<tbody> 205<tr> 206<td><span class="term"><i><tt>buf</tt></i>:</span></td> 207<td>the result buffer.</td> 208</tr> 209<tr> 210<td><span class="term"><i><tt>len</tt></i>:</span></td> 211<td>the result buffer length.</td> 212</tr> 213<tr> 214<td><span class="term"><i><tt>msg</tt></i>:</span></td> 215<td>the message with printf formatting.</td> 216</tr> 217<tr> 218<td><span class="term"><i><tt>...</tt></i>:</span></td> 219<td>extra parameters for the message.</td> 220</tr> 221<tr> 222<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 223<td>the number of <a href="libxml2-SAX.html#characters">characters</a> written to @buf or -1 if an error occurs.</td> 224</tr> 225</tbody> 226</table></div> 227</div> 228<hr> 229<div class="refsect2" lang="en"> 230<h3> 231<a name="xmlStrQEqual"></a>xmlStrQEqual ()</h3> 232<pre class="programlisting">int xmlStrQEqual (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * pref, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str)<br> 233</pre> 234<p>Check if a QName is Equal to a given string</p> 235<div class="variablelist"><table border="0"> 236<col align="left"> 237<tbody> 238<tr> 239<td><span class="term"><i><tt>pref</tt></i>:</span></td> 240<td>the prefix of the QName</td> 241</tr> 242<tr> 243<td><span class="term"><i><tt>name</tt></i>:</span></td> 244<td>the localname of the QName</td> 245</tr> 246<tr> 247<td><span class="term"><i><tt>str</tt></i>:</span></td> 248<td>the second <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *</td> 249</tr> 250<tr> 251<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 252<td>1 if they are equal, 0 if they are different</td> 253</tr> 254</tbody> 255</table></div> 256</div> 257<hr> 258<div class="refsect2" lang="en"> 259<h3> 260<a name="xmlStrVPrintf"></a>xmlStrVPrintf ()</h3> 261<pre class="programlisting">int xmlStrVPrintf (<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * buf, <br> int len, <br> const char * msg, <br> va_list ap)<br> 262</pre> 263<p>Formats @msg and places result into @buf.</p> 264<div class="variablelist"><table border="0"> 265<col align="left"> 266<tbody> 267<tr> 268<td><span class="term"><i><tt>buf</tt></i>:</span></td> 269<td>the result buffer.</td> 270</tr> 271<tr> 272<td><span class="term"><i><tt>len</tt></i>:</span></td> 273<td>the result buffer length.</td> 274</tr> 275<tr> 276<td><span class="term"><i><tt>msg</tt></i>:</span></td> 277<td>the message with printf formatting.</td> 278</tr> 279<tr> 280<td><span class="term"><i><tt>ap</tt></i>:</span></td> 281<td>extra parameters for the message.</td> 282</tr> 283<tr> 284<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 285<td>the number of <a href="libxml2-SAX.html#characters">characters</a> written to @buf or -1 if an error occurs.</td> 286</tr> 287</tbody> 288</table></div> 289</div> 290<hr> 291<div class="refsect2" lang="en"> 292<h3> 293<a name="xmlStrcasecmp"></a>xmlStrcasecmp ()</h3> 294<pre class="programlisting">int xmlStrcasecmp (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str1, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str2)<br> 295</pre> 296<p>a strcasecmp for xmlChar's</p> 297<div class="variablelist"><table border="0"> 298<col align="left"> 299<tbody> 300<tr> 301<td><span class="term"><i><tt>str1</tt></i>:</span></td> 302<td>the first <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *</td> 303</tr> 304<tr> 305<td><span class="term"><i><tt>str2</tt></i>:</span></td> 306<td>the second <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *</td> 307</tr> 308<tr> 309<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 310<td>the integer result of the comparison</td> 311</tr> 312</tbody> 313</table></div> 314</div> 315<hr> 316<div class="refsect2" lang="en"> 317<h3> 318<a name="xmlStrcasestr"></a>xmlStrcasestr ()</h3> 319<pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlStrcasestr (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * val)<br> 320</pre> 321<p>a case-ignoring strstr for xmlChar's</p> 322<div class="variablelist"><table border="0"> 323<col align="left"> 324<tbody> 325<tr> 326<td><span class="term"><i><tt>str</tt></i>:</span></td> 327<td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array (haystack)</td> 328</tr> 329<tr> 330<td><span class="term"><i><tt>val</tt></i>:</span></td> 331<td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> to search (needle)</td> 332</tr> 333<tr> 334<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 335<td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * for the first occurrence or NULL.</td> 336</tr> 337</tbody> 338</table></div> 339</div> 340<hr> 341<div class="refsect2" lang="en"> 342<h3> 343<a name="xmlStrcat"></a>xmlStrcat ()</h3> 344<pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlStrcat (<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * add)<br> 345</pre> 346<p>a strcat for array of xmlChar's. Since they are supposed to be encoded in UTF-8 or an encoding with 8bit based chars, we assume a termination mark of '0'.</p> 347<div class="variablelist"><table border="0"> 348<col align="left"> 349<tbody> 350<tr> 351<td><span class="term"><i><tt>cur</tt></i>:</span></td> 352<td>the original <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array</td> 353</tr> 354<tr> 355<td><span class="term"><i><tt>add</tt></i>:</span></td> 356<td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array added</td> 357</tr> 358<tr> 359<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 360<td>a new <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * containing the concatenated string. The original @cur is reallocated and should not be freed.</td> 361</tr> 362</tbody> 363</table></div> 364</div> 365<hr> 366<div class="refsect2" lang="en"> 367<h3> 368<a name="xmlStrchr"></a>xmlStrchr ()</h3> 369<pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlStrchr (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br> <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> val)<br> 370</pre> 371<p>a strchr for xmlChar's</p> 372<div class="variablelist"><table border="0"> 373<col align="left"> 374<tbody> 375<tr> 376<td><span class="term"><i><tt>str</tt></i>:</span></td> 377<td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array</td> 378</tr> 379<tr> 380<td><span class="term"><i><tt>val</tt></i>:</span></td> 381<td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> to search</td> 382</tr> 383<tr> 384<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 385<td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * for the first occurrence or NULL.</td> 386</tr> 387</tbody> 388</table></div> 389</div> 390<hr> 391<div class="refsect2" lang="en"> 392<h3> 393<a name="xmlStrcmp"></a>xmlStrcmp ()</h3> 394<pre class="programlisting">int xmlStrcmp (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str1, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str2)<br> 395</pre> 396<p>a strcmp for xmlChar's</p> 397<div class="variablelist"><table border="0"> 398<col align="left"> 399<tbody> 400<tr> 401<td><span class="term"><i><tt>str1</tt></i>:</span></td> 402<td>the first <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *</td> 403</tr> 404<tr> 405<td><span class="term"><i><tt>str2</tt></i>:</span></td> 406<td>the second <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *</td> 407</tr> 408<tr> 409<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 410<td>the integer result of the comparison</td> 411</tr> 412</tbody> 413</table></div> 414</div> 415<hr> 416<div class="refsect2" lang="en"> 417<h3> 418<a name="xmlStrdup"></a>xmlStrdup ()</h3> 419<pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlStrdup (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur)<br> 420</pre> 421<p>a strdup for array of xmlChar's. Since they are supposed to be encoded in UTF-8 or an encoding with 8bit based chars, we assume a termination mark of '0'.</p> 422<div class="variablelist"><table border="0"> 423<col align="left"> 424<tbody> 425<tr> 426<td><span class="term"><i><tt>cur</tt></i>:</span></td> 427<td>the input <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *</td> 428</tr> 429<tr> 430<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 431<td>a new <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * or NULL</td> 432</tr> 433</tbody> 434</table></div> 435</div> 436<hr> 437<div class="refsect2" lang="en"> 438<h3> 439<a name="xmlStrlen"></a>xmlStrlen ()</h3> 440<pre class="programlisting">int xmlStrlen (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str)<br> 441</pre> 442<p>length of a xmlChar's string</p> 443<div class="variablelist"><table border="0"> 444<col align="left"> 445<tbody> 446<tr> 447<td><span class="term"><i><tt>str</tt></i>:</span></td> 448<td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array</td> 449</tr> 450<tr> 451<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 452<td>the number of <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> contained in the ARRAY.</td> 453</tr> 454</tbody> 455</table></div> 456</div> 457<hr> 458<div class="refsect2" lang="en"> 459<h3> 460<a name="xmlStrncasecmp"></a>xmlStrncasecmp ()</h3> 461<pre class="programlisting">int xmlStrncasecmp (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str1, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str2, <br> int len)<br> 462</pre> 463<p>a strncasecmp for xmlChar's</p> 464<div class="variablelist"><table border="0"> 465<col align="left"> 466<tbody> 467<tr> 468<td><span class="term"><i><tt>str1</tt></i>:</span></td> 469<td>the first <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *</td> 470</tr> 471<tr> 472<td><span class="term"><i><tt>str2</tt></i>:</span></td> 473<td>the second <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *</td> 474</tr> 475<tr> 476<td><span class="term"><i><tt>len</tt></i>:</span></td> 477<td>the max comparison length</td> 478</tr> 479<tr> 480<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 481<td>the integer result of the comparison</td> 482</tr> 483</tbody> 484</table></div> 485</div> 486<hr> 487<div class="refsect2" lang="en"> 488<h3> 489<a name="xmlStrncat"></a>xmlStrncat ()</h3> 490<pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlStrncat (<a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * add, <br> int len)<br> 491</pre> 492<p>a strncat for array of xmlChar's, it will extend @cur with the len first bytes of @add. Note that if @len < 0 then this is an API error and NULL will be returned.</p> 493<div class="variablelist"><table border="0"> 494<col align="left"> 495<tbody> 496<tr> 497<td><span class="term"><i><tt>cur</tt></i>:</span></td> 498<td>the original <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array</td> 499</tr> 500<tr> 501<td><span class="term"><i><tt>add</tt></i>:</span></td> 502<td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array added</td> 503</tr> 504<tr> 505<td><span class="term"><i><tt>len</tt></i>:</span></td> 506<td>the length of @add</td> 507</tr> 508<tr> 509<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 510<td>a new <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *, the original @cur is reallocated and should not be freed.</td> 511</tr> 512</tbody> 513</table></div> 514</div> 515<hr> 516<div class="refsect2" lang="en"> 517<h3> 518<a name="xmlStrncatNew"></a>xmlStrncatNew ()</h3> 519<pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlStrncatNew (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str1, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str2, <br> int len)<br> 520</pre> 521<p>same as xmlStrncat, but creates a new string. The original two strings are not freed. If @len is < 0 then the length will be calculated automatically.</p> 522<div class="variablelist"><table border="0"> 523<col align="left"> 524<tbody> 525<tr> 526<td><span class="term"><i><tt>str1</tt></i>:</span></td> 527<td>first <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> string</td> 528</tr> 529<tr> 530<td><span class="term"><i><tt>str2</tt></i>:</span></td> 531<td>second <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> string</td> 532</tr> 533<tr> 534<td><span class="term"><i><tt>len</tt></i>:</span></td> 535<td>the len of @str2 or < 0</td> 536</tr> 537<tr> 538<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 539<td>a new <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * or NULL</td> 540</tr> 541</tbody> 542</table></div> 543</div> 544<hr> 545<div class="refsect2" lang="en"> 546<h3> 547<a name="xmlStrncmp"></a>xmlStrncmp ()</h3> 548<pre class="programlisting">int xmlStrncmp (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str1, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str2, <br> int len)<br> 549</pre> 550<p>a strncmp for xmlChar's</p> 551<div class="variablelist"><table border="0"> 552<col align="left"> 553<tbody> 554<tr> 555<td><span class="term"><i><tt>str1</tt></i>:</span></td> 556<td>the first <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *</td> 557</tr> 558<tr> 559<td><span class="term"><i><tt>str2</tt></i>:</span></td> 560<td>the second <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *</td> 561</tr> 562<tr> 563<td><span class="term"><i><tt>len</tt></i>:</span></td> 564<td>the max comparison length</td> 565</tr> 566<tr> 567<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 568<td>the integer result of the comparison</td> 569</tr> 570</tbody> 571</table></div> 572</div> 573<hr> 574<div class="refsect2" lang="en"> 575<h3> 576<a name="xmlStrndup"></a>xmlStrndup ()</h3> 577<pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlStrndup (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * cur, <br> int len)<br> 578</pre> 579<p>a strndup for array of xmlChar's</p> 580<div class="variablelist"><table border="0"> 581<col align="left"> 582<tbody> 583<tr> 584<td><span class="term"><i><tt>cur</tt></i>:</span></td> 585<td>the input <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *</td> 586</tr> 587<tr> 588<td><span class="term"><i><tt>len</tt></i>:</span></td> 589<td>the len of @cur</td> 590</tr> 591<tr> 592<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 593<td>a new <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * or NULL</td> 594</tr> 595</tbody> 596</table></div> 597</div> 598<hr> 599<div class="refsect2" lang="en"> 600<h3> 601<a name="xmlStrstr"></a>xmlStrstr ()</h3> 602<pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlStrstr (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * val)<br> 603</pre> 604<p>a strstr for xmlChar's</p> 605<div class="variablelist"><table border="0"> 606<col align="left"> 607<tbody> 608<tr> 609<td><span class="term"><i><tt>str</tt></i>:</span></td> 610<td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array (haystack)</td> 611</tr> 612<tr> 613<td><span class="term"><i><tt>val</tt></i>:</span></td> 614<td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> to search (needle)</td> 615</tr> 616<tr> 617<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 618<td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * for the first occurrence or NULL.</td> 619</tr> 620</tbody> 621</table></div> 622</div> 623<hr> 624<div class="refsect2" lang="en"> 625<h3> 626<a name="xmlStrsub"></a>xmlStrsub ()</h3> 627<pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlStrsub (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str, <br> int start, <br> int len)<br> 628</pre> 629<p>Extract a substring of a given string</p> 630<div class="variablelist"><table border="0"> 631<col align="left"> 632<tbody> 633<tr> 634<td><span class="term"><i><tt>str</tt></i>:</span></td> 635<td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * array (haystack)</td> 636</tr> 637<tr> 638<td><span class="term"><i><tt>start</tt></i>:</span></td> 639<td>the index of the first char (zero based)</td> 640</tr> 641<tr> 642<td><span class="term"><i><tt>len</tt></i>:</span></td> 643<td>the length of the substring</td> 644</tr> 645<tr> 646<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 647<td>the <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * for the first occurrence or NULL.</td> 648</tr> 649</tbody> 650</table></div> 651</div> 652<hr> 653<div class="refsect2" lang="en"> 654<h3> 655<a name="xmlUTF8Charcmp"></a>xmlUTF8Charcmp ()</h3> 656<pre class="programlisting">int xmlUTF8Charcmp (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf1, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf2)<br> 657</pre> 658<p>compares the two UCS4 values</p> 659<div class="variablelist"><table border="0"> 660<col align="left"> 661<tbody> 662<tr> 663<td><span class="term"><i><tt>utf1</tt></i>:</span></td> 664<td>pointer to first UTF8 char</td> 665</tr> 666<tr> 667<td><span class="term"><i><tt>utf2</tt></i>:</span></td> 668<td>pointer to second UTF8 char</td> 669</tr> 670<tr> 671<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 672<td>result of the compare as with <a href="libxml2-xmlstring.html#xmlStrncmp">xmlStrncmp</a> 673</td> 674</tr> 675</tbody> 676</table></div> 677</div> 678<hr> 679<div class="refsect2" lang="en"> 680<h3> 681<a name="xmlUTF8Size"></a>xmlUTF8Size ()</h3> 682<pre class="programlisting">int xmlUTF8Size (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf)<br> 683</pre> 684<p>calculates the internal size of a UTF8 character</p> 685<div class="variablelist"><table border="0"> 686<col align="left"> 687<tbody> 688<tr> 689<td><span class="term"><i><tt>utf</tt></i>:</span></td> 690<td>pointer to the UTF8 character</td> 691</tr> 692<tr> 693<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 694<td>the numbers of bytes in the character, -1 on format error</td> 695</tr> 696</tbody> 697</table></div> 698</div> 699<hr> 700<div class="refsect2" lang="en"> 701<h3> 702<a name="xmlUTF8Strlen"></a>xmlUTF8Strlen ()</h3> 703<pre class="programlisting">int xmlUTF8Strlen (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf)<br> 704</pre> 705<p>compute the length of an UTF8 string, it doesn't do a full UTF8 checking of the content of the string.</p> 706<div class="variablelist"><table border="0"> 707<col align="left"> 708<tbody> 709<tr> 710<td><span class="term"><i><tt>utf</tt></i>:</span></td> 711<td>a sequence of UTF-8 encoded bytes</td> 712</tr> 713<tr> 714<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 715<td>the number of <a href="libxml2-SAX.html#characters">characters</a> in the string or -1 in case of error</td> 716</tr> 717</tbody> 718</table></div> 719</div> 720<hr> 721<div class="refsect2" lang="en"> 722<h3> 723<a name="xmlUTF8Strloc"></a>xmlUTF8Strloc ()</h3> 724<pre class="programlisting">int xmlUTF8Strloc (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utfchar)<br> 725</pre> 726<p>a function to provide the relative location of a UTF8 char</p> 727<div class="variablelist"><table border="0"> 728<col align="left"> 729<tbody> 730<tr> 731<td><span class="term"><i><tt>utf</tt></i>:</span></td> 732<td>the input UTF8 *</td> 733</tr> 734<tr> 735<td><span class="term"><i><tt>utfchar</tt></i>:</span></td> 736<td>the UTF8 character to be found</td> 737</tr> 738<tr> 739<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 740<td>the relative character position of the desired char or -1 if not found</td> 741</tr> 742</tbody> 743</table></div> 744</div> 745<hr> 746<div class="refsect2" lang="en"> 747<h3> 748<a name="xmlUTF8Strndup"></a>xmlUTF8Strndup ()</h3> 749<pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlUTF8Strndup (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf, <br> int len)<br> 750</pre> 751<p>a strndup for array of UTF8's</p> 752<div class="variablelist"><table border="0"> 753<col align="left"> 754<tbody> 755<tr> 756<td><span class="term"><i><tt>utf</tt></i>:</span></td> 757<td>the input UTF8 *</td> 758</tr> 759<tr> 760<td><span class="term"><i><tt>len</tt></i>:</span></td> 761<td>the len of @utf (in chars)</td> 762</tr> 763<tr> 764<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 765<td>a new UTF8 * or NULL</td> 766</tr> 767</tbody> 768</table></div> 769</div> 770<hr> 771<div class="refsect2" lang="en"> 772<h3> 773<a name="xmlUTF8Strpos"></a>xmlUTF8Strpos ()</h3> 774<pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlUTF8Strpos (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf, <br> int pos)<br> 775</pre> 776<p>a function to provide the equivalent of fetching a character from a string array</p> 777<div class="variablelist"><table border="0"> 778<col align="left"> 779<tbody> 780<tr> 781<td><span class="term"><i><tt>utf</tt></i>:</span></td> 782<td>the input UTF8 *</td> 783</tr> 784<tr> 785<td><span class="term"><i><tt>pos</tt></i>:</span></td> 786<td>the position of the desired UTF8 char (in chars)</td> 787</tr> 788<tr> 789<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 790<td>a pointer to the UTF8 character or NULL</td> 791</tr> 792</tbody> 793</table></div> 794</div> 795<hr> 796<div class="refsect2" lang="en"> 797<h3> 798<a name="xmlUTF8Strsize"></a>xmlUTF8Strsize ()</h3> 799<pre class="programlisting">int xmlUTF8Strsize (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf, <br> int len)<br> 800</pre> 801<p>storage size of an UTF8 string the behaviour is not guaranteed if the input string is not UTF-8</p> 802<div class="variablelist"><table border="0"> 803<col align="left"> 804<tbody> 805<tr> 806<td><span class="term"><i><tt>utf</tt></i>:</span></td> 807<td>a sequence of UTF-8 encoded bytes</td> 808</tr> 809<tr> 810<td><span class="term"><i><tt>len</tt></i>:</span></td> 811<td>the number of <a href="libxml2-SAX.html#characters">characters</a> in the array</td> 812</tr> 813<tr> 814<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 815<td>the storage size of the first 'len' <a href="libxml2-SAX.html#characters">characters</a> of ARRAY</td> 816</tr> 817</tbody> 818</table></div> 819</div> 820<hr> 821<div class="refsect2" lang="en"> 822<h3> 823<a name="xmlUTF8Strsub"></a>xmlUTF8Strsub ()</h3> 824<pre class="programlisting"><a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlUTF8Strsub (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * utf, <br> int start, <br> int len)<br> 825</pre> 826<p>Create a substring from a given UTF-8 string Note: positions are given in units of UTF-8 chars</p> 827<div class="variablelist"><table border="0"> 828<col align="left"> 829<tbody> 830<tr> 831<td><span class="term"><i><tt>utf</tt></i>:</span></td> 832<td>a sequence of UTF-8 encoded bytes</td> 833</tr> 834<tr> 835<td><span class="term"><i><tt>start</tt></i>:</span></td> 836<td>relative pos of first char</td> 837</tr> 838<tr> 839<td><span class="term"><i><tt>len</tt></i>:</span></td> 840<td>total number to copy</td> 841</tr> 842<tr> 843<td><span class="term"><i><tt>Returns</tt></i>:</span></td> 844<td>a pointer to a newly created string or NULL if any problem</td> 845</tr> 846</tbody> 847</table></div> 848</div> 849<hr> 850</div> 851</div> 852</body> 853</html> 854