<!-- This comment will put IE 6, 7 and 8 in quirks mode --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>ICU 4.4.1: utf8.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javaScript" src="search/search.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body onload='searchBox.OnSelectItem(0);'> <!-- Generated by Doxygen 1.6.2-20100208 --> <script type="text/javascript"><!-- var searchBox = new SearchBox("searchBox", "search",false,'Search'); --></script> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <img id="MSearchSelect" src="search/search.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </div> </li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <h1>utf8.h</h1><a href="utf8_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment">*******************************************************************************</span> <a name="l00003"></a>00003 <span class="comment">*</span> <a name="l00004"></a>00004 <span class="comment">* Copyright (C) 1999-2009, International Business Machines</span> <a name="l00005"></a>00005 <span class="comment">* Corporation and others. All Rights Reserved.</span> <a name="l00006"></a>00006 <span class="comment">*</span> <a name="l00007"></a>00007 <span class="comment">*******************************************************************************</span> <a name="l00008"></a>00008 <span class="comment">* file name: utf8.h</span> <a name="l00009"></a>00009 <span class="comment">* encoding: US-ASCII</span> <a name="l00010"></a>00010 <span class="comment">* tab size: 8 (not used)</span> <a name="l00011"></a>00011 <span class="comment">* indentation:4</span> <a name="l00012"></a>00012 <span class="comment">*</span> <a name="l00013"></a>00013 <span class="comment">* created on: 1999sep13</span> <a name="l00014"></a>00014 <span class="comment">* created by: Markus W. Scherer</span> <a name="l00015"></a>00015 <span class="comment">*/</span> <a name="l00016"></a>00016 <a name="l00034"></a>00034 <span class="preprocessor">#ifndef __UTF8_H__</span> <a name="l00035"></a>00035 <span class="preprocessor"></span><span class="preprocessor">#define __UTF8_H__</span> <a name="l00036"></a>00036 <span class="preprocessor"></span> <a name="l00037"></a>00037 <span class="comment">/* utf.h must be included first. */</span> <a name="l00038"></a>00038 <span class="preprocessor">#ifndef __UTF_H__</span> <a name="l00039"></a>00039 <span class="preprocessor"></span><span class="preprocessor"># include "<a class="code" href="utf_8h.html" title="C API: Code point macros.">unicode/utf.h</a>"</span> <a name="l00040"></a>00040 <span class="preprocessor">#endif</span> <a name="l00041"></a>00041 <span class="preprocessor"></span> <a name="l00042"></a>00042 <span class="comment">/* internal definitions ----------------------------------------------------- */</span> <a name="l00043"></a>00043 <a name="l00055"></a>00055 <span class="preprocessor">#ifdef U_UTF8_IMPL</span> <a name="l00056"></a>00056 <span class="preprocessor"></span><a class="code" href="platform_8h.html#a7d78411159504c2d6770763f924a1792">U_EXPORT</a> <span class="keyword">const</span> uint8_t <a name="l00057"></a>00057 <span class="preprocessor">#elif defined(U_STATIC_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION)</span> <a name="l00058"></a>00058 <span class="preprocessor"></span><a class="code" href="umachine_8h.html#af702d65cba0638c5a8194cccc8d7c39e" title="This is used in a declaration of a library private ICU C function.">U_CFUNC</a> <span class="keyword">const</span> uint8_t <a name="l00059"></a>00059 <span class="preprocessor">#else</span> <a name="l00060"></a>00060 <span class="preprocessor"></span><a class="code" href="umachine_8h.html#af702d65cba0638c5a8194cccc8d7c39e" title="This is used in a declaration of a library private ICU C function.">U_CFUNC</a> <a class="code" href="platform_8h.html#a4099e2ee510ce74ddacfc2010306b8b5">U_IMPORT</a> <span class="keyword">const</span> uint8_t <span class="comment">/* U_IMPORT2? */</span> <span class="comment">/*U_IMPORT*/</span> <a name="l00061"></a>00061 <span class="preprocessor">#endif</span> <a name="l00062"></a><a class="code" href="utf8_8h.html#a4e3ae25d5856272ab60ab87c28572a99">00062</a> <span class="preprocessor"></span><a class="code" href="utf8_8h.html#a4e3ae25d5856272ab60ab87c28572a99" title="Internal array with numbers of trail bytes for any given byte used in lead byte position...">utf8_countTrailBytes</a>[256]; <a name="l00063"></a>00063 <a name="l00071"></a><a class="code" href="utf8_8h.html#ae534bfef078b4f5d09e8da543a779db7">00071</a> <span class="preprocessor">#define U8_COUNT_TRAIL_BYTES(leadByte) (utf8_countTrailBytes[(uint8_t)leadByte])</span> <a name="l00072"></a>00072 <span class="preprocessor"></span> <a name="l00080"></a><a class="code" href="utf8_8h.html#ae8ed1045986b8bf27814e9bc78388961">00080</a> <span class="preprocessor">#define U8_MASK_LEAD_BYTE(leadByte, countTrailBytes) ((leadByte)&=(1<<(6-(countTrailBytes)))-1)</span> <a name="l00081"></a>00081 <span class="preprocessor"></span> <a name="l00091"></a>00091 <a class="code" href="umachine_8h.html#af3e3799716eaa41e3f49c7bf18c62b98" title="This is used to declare a function as a stable public ICU C API.">U_STABLE</a> <a class="code" href="umachine_8h.html#a09fff5c3b5a5b015324dc3ec3cf92809" title="Define UChar32 as a type for single Unicode code points.">UChar32</a> <a class="code" href="platform_8h.html#a72bf6d8ec0640a37b1915e5d853b2016">U_EXPORT2</a> <a name="l00092"></a>00092 <a class="code" href="utf8_8h.html#a6eaf56eb54abb71eafcc0c347daa821f" title="Function for handling &quot;next code point&quot; with error-checking.">utf8_nextCharSafeBody</a>(<span class="keyword">const</span> uint8_t *s, int32_t *pi, int32_t length, <a class="code" href="umachine_8h.html#a09fff5c3b5a5b015324dc3ec3cf92809" title="Define UChar32 as a type for single Unicode code points.">UChar32</a> c, <a class="code" href="umachine_8h.html#a349ef00011f20ccd1d3b424445681aa5" title="The ICU boolean type.">UBool</a> strict); <a name="l00093"></a>00093 <a name="l00103"></a>00103 <a class="code" href="umachine_8h.html#af3e3799716eaa41e3f49c7bf18c62b98" title="This is used to declare a function as a stable public ICU C API.">U_STABLE</a> int32_t <a class="code" href="platform_8h.html#a72bf6d8ec0640a37b1915e5d853b2016">U_EXPORT2</a> <a name="l00104"></a>00104 <a class="code" href="utf8_8h.html#a6cf17491f1c237bbe5b002056b830fd3" title="Function for handling &quot;append code point&quot; with error-checking.">utf8_appendCharSafeBody</a>(uint8_t *s, int32_t i, int32_t length, <a class="code" href="umachine_8h.html#a09fff5c3b5a5b015324dc3ec3cf92809" title="Define UChar32 as a type for single Unicode code points.">UChar32</a> c, <a class="code" href="umachine_8h.html#a349ef00011f20ccd1d3b424445681aa5" title="The ICU boolean type.">UBool</a> *pIsError); <a name="l00105"></a>00105 <a name="l00115"></a>00115 <a class="code" href="umachine_8h.html#af3e3799716eaa41e3f49c7bf18c62b98" title="This is used to declare a function as a stable public ICU C API.">U_STABLE</a> <a class="code" href="umachine_8h.html#a09fff5c3b5a5b015324dc3ec3cf92809" title="Define UChar32 as a type for single Unicode code points.">UChar32</a> <a class="code" href="platform_8h.html#a72bf6d8ec0640a37b1915e5d853b2016">U_EXPORT2</a> <a name="l00116"></a>00116 <a class="code" href="utf8_8h.html#a2bbae41d2d845750088a17dc55f59096" title="Function for handling &quot;previous code point&quot; with error-checking.">utf8_prevCharSafeBody</a>(<span class="keyword">const</span> uint8_t *s, int32_t start, int32_t *pi, <a class="code" href="umachine_8h.html#a09fff5c3b5a5b015324dc3ec3cf92809" title="Define UChar32 as a type for single Unicode code points.">UChar32</a> c, <a class="code" href="umachine_8h.html#a349ef00011f20ccd1d3b424445681aa5" title="The ICU boolean type.">UBool</a> strict); <a name="l00117"></a>00117 <a name="l00127"></a>00127 <a class="code" href="umachine_8h.html#af3e3799716eaa41e3f49c7bf18c62b98" title="This is used to declare a function as a stable public ICU C API.">U_STABLE</a> int32_t <a class="code" href="platform_8h.html#a72bf6d8ec0640a37b1915e5d853b2016">U_EXPORT2</a> <a name="l00128"></a>00128 <a class="code" href="utf8_8h.html#a4017310e2ecadac7dea5a432a33ccf30" title="Function for handling &quot;skip backward one code point&quot; with error-checking...">utf8_back1SafeBody</a>(<span class="keyword">const</span> uint8_t *s, int32_t start, int32_t i); <a name="l00129"></a>00129 <a name="l00130"></a>00130 <span class="comment">/* single-code point definitions -------------------------------------------- */</span> <a name="l00131"></a>00131 <a name="l00138"></a><a class="code" href="utf8_8h.html#a8f3a9427d880458a9fa6b169a3cc1b3c">00138</a> <span class="preprocessor">#define U8_IS_SINGLE(c) (((c)&0x80)==0)</span> <a name="l00139"></a>00139 <span class="preprocessor"></span> <a name="l00146"></a><a class="code" href="utf8_8h.html#adb9837ea38dd811524a5b761ddc2a2ca">00146</a> <span class="preprocessor">#define U8_IS_LEAD(c) ((uint8_t)((c)-0xc0)<0x3e)</span> <a name="l00147"></a>00147 <span class="preprocessor"></span> <a name="l00154"></a><a class="code" href="utf8_8h.html#afed9fc9bf480bf15a2e6051774f2d80e">00154</a> <span class="preprocessor">#define U8_IS_TRAIL(c) (((c)&0xc0)==0x80)</span> <a name="l00155"></a>00155 <span class="preprocessor"></span> <a name="l00163"></a><a class="code" href="utf8_8h.html#af1730b8bbb3053465ee58702821846f1">00163</a> <span class="preprocessor">#define U8_LENGTH(c) \</span> <a name="l00164"></a>00164 <span class="preprocessor"> ((uint32_t)(c)<=0x7f ? 1 : \</span> <a name="l00165"></a>00165 <span class="preprocessor"> ((uint32_t)(c)<=0x7ff ? 2 : \</span> <a name="l00166"></a>00166 <span class="preprocessor"> ((uint32_t)(c)<=0xd7ff ? 3 : \</span> <a name="l00167"></a>00167 <span class="preprocessor"> ((uint32_t)(c)<=0xdfff || (uint32_t)(c)>0x10ffff ? 0 : \</span> <a name="l00168"></a>00168 <span class="preprocessor"> ((uint32_t)(c)<=0xffff ? 3 : 4)\</span> <a name="l00169"></a>00169 <span class="preprocessor"> ) \</span> <a name="l00170"></a>00170 <span class="preprocessor"> ) \</span> <a name="l00171"></a>00171 <span class="preprocessor"> ) \</span> <a name="l00172"></a>00172 <span class="preprocessor"> )</span> <a name="l00173"></a>00173 <span class="preprocessor"></span> <a name="l00179"></a><a class="code" href="utf8_8h.html#aa2298b48749d9f45772c8f5a6885464a">00179</a> <span class="preprocessor">#define U8_MAX_LENGTH 4</span> <a name="l00180"></a>00180 <span class="preprocessor"></span> <a name="l00197"></a><a class="code" href="utf8_8h.html#a125e5e7a4ef2f3f57b078f706b2b67f8">00197</a> <span class="preprocessor">#define U8_GET_UNSAFE(s, i, c) { \</span> <a name="l00198"></a>00198 <span class="preprocessor"> int32_t _u8_get_unsafe_index=(int32_t)(i); \</span> <a name="l00199"></a>00199 <span class="preprocessor"> U8_SET_CP_START_UNSAFE(s, _u8_get_unsafe_index); \</span> <a name="l00200"></a>00200 <span class="preprocessor"> U8_NEXT_UNSAFE(s, _u8_get_unsafe_index, c); \</span> <a name="l00201"></a>00201 <span class="preprocessor">}</span> <a name="l00202"></a>00202 <span class="preprocessor"></span> <a name="l00221"></a><a class="code" href="utf8_8h.html#a10a57a084d75604c4a81fb5eec46ae6a">00221</a> <span class="preprocessor">#define U8_GET(s, start, i, length, c) { \</span> <a name="l00222"></a>00222 <span class="preprocessor"> int32_t _u8_get_index=(int32_t)(i); \</span> <a name="l00223"></a>00223 <span class="preprocessor"> U8_SET_CP_START(s, start, _u8_get_index); \</span> <a name="l00224"></a>00224 <span class="preprocessor"> U8_NEXT(s, _u8_get_index, length, c); \</span> <a name="l00225"></a>00225 <span class="preprocessor">}</span> <a name="l00226"></a>00226 <span class="preprocessor"></span> <a name="l00227"></a>00227 <span class="comment">/* definitions with forward iteration --------------------------------------- */</span> <a name="l00228"></a>00228 <a name="l00246"></a><a class="code" href="utf8_8h.html#a28ecdb4233301285fc4ce7f9ea1ed644">00246</a> <span class="preprocessor">#define U8_NEXT_UNSAFE(s, i, c) { \</span> <a name="l00247"></a>00247 <span class="preprocessor"> (c)=(uint8_t)(s)[(i)++]; \</span> <a name="l00248"></a>00248 <span class="preprocessor"> if((uint8_t)((c)-0xc0)<0x35) { \</span> <a name="l00249"></a>00249 <span class="preprocessor"> uint8_t __count=U8_COUNT_TRAIL_BYTES(c); \</span> <a name="l00250"></a>00250 <span class="preprocessor"> U8_MASK_LEAD_BYTE(c, __count); \</span> <a name="l00251"></a>00251 <span class="preprocessor"> switch(__count) { \</span> <a name="l00252"></a>00252 <span class="preprocessor"> </span><span class="comment">/* each following branch falls through to the next one */</span> \ <a name="l00253"></a>00253 case 3: \ <a name="l00254"></a>00254 (c)=((c)<<6)|((s)[(i)++]&0x3f); \ <a name="l00255"></a>00255 case 2: \ <a name="l00256"></a>00256 (c)=((c)<<6)|((s)[(i)++]&0x3f); \ <a name="l00257"></a>00257 case 1: \ <a name="l00258"></a>00258 (c)=((c)<<6)|((s)[(i)++]&0x3f); \ <a name="l00259"></a>00259 <span class="comment">/* no other branches to optimize switch() */</span> \ <a name="l00260"></a>00260 break; \ <a name="l00261"></a>00261 } \ <a name="l00262"></a>00262 } \ <a name="l00263"></a>00263 } <a name="l00264"></a>00264 <a name="l00283"></a><a class="code" href="utf8_8h.html#a57f3e5429ae4edb27a42367c627aa482">00283</a> <span class="preprocessor">#define U8_NEXT(s, i, length, c) { \</span> <a name="l00284"></a>00284 <span class="preprocessor"> (c)=(uint8_t)(s)[(i)++]; \</span> <a name="l00285"></a>00285 <span class="preprocessor"> if((c)>=0x80) { \</span> <a name="l00286"></a>00286 <span class="preprocessor"> uint8_t __t1, __t2; \</span> <a name="l00287"></a>00287 <span class="preprocessor"> if( </span><span class="comment">/* handle U+1000..U+CFFF inline */</span> \ <a name="l00288"></a>00288 (0xe0<(c) && (c)<=0xec) && \ <a name="l00289"></a>00289 (((i)+1)<(length)) && \ <a name="l00290"></a>00290 (__t1=(uint8_t)((s)[i]-0x80))<=0x3f && \ <a name="l00291"></a>00291 (__t2=(uint8_t)((s)[(i)+1]-0x80))<= 0x3f \ <a name="l00292"></a>00292 ) { \ <a name="l00293"></a>00293 <span class="comment">/* no need for (c&0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */</span> \ <a name="l00294"></a>00294 (c)=(UChar)(((c)<<12)|(__t1<<6)|__t2); \ <a name="l00295"></a>00295 (i)+=2; \ <a name="l00296"></a>00296 } else if( <span class="comment">/* handle U+0080..U+07FF inline */</span> \ <a name="l00297"></a>00297 ((c)<0xe0 && (c)>=0xc2) && \ <a name="l00298"></a>00298 ((i)<(length)) && \ <a name="l00299"></a>00299 (__t1=(uint8_t)((s)[i]-0x80))<=0x3f \ <a name="l00300"></a>00300 ) { \ <a name="l00301"></a>00301 (c)=(UChar)((((c)&0x1f)<<6)|__t1); \ <a name="l00302"></a>00302 ++(i); \ <a name="l00303"></a>00303 } else if(U8_IS_LEAD(c)) { \ <a name="l00304"></a>00304 <span class="comment">/* function call for "complicated" and error cases */</span> \ <a name="l00305"></a>00305 (c)=utf8_nextCharSafeBody((const uint8_t *)s, &(i), (int32_t)(length), c, -1); \ <a name="l00306"></a>00306 } else { \ <a name="l00307"></a>00307 (c)=U_SENTINEL; \ <a name="l00308"></a>00308 } \ <a name="l00309"></a>00309 } \ <a name="l00310"></a>00310 } <a name="l00311"></a>00311 <a name="l00325"></a><a class="code" href="utf8_8h.html#a154f04764da5af41729c4df6bf9e09f3">00325</a> <span class="preprocessor">#define U8_APPEND_UNSAFE(s, i, c) { \</span> <a name="l00326"></a>00326 <span class="preprocessor"> if((uint32_t)(c)<=0x7f) { \</span> <a name="l00327"></a>00327 <span class="preprocessor"> (s)[(i)++]=(uint8_t)(c); \</span> <a name="l00328"></a>00328 <span class="preprocessor"> } else { \</span> <a name="l00329"></a>00329 <span class="preprocessor"> if((uint32_t)(c)<=0x7ff) { \</span> <a name="l00330"></a>00330 <span class="preprocessor"> (s)[(i)++]=(uint8_t)(((c)>>6)|0xc0); \</span> <a name="l00331"></a>00331 <span class="preprocessor"> } else { \</span> <a name="l00332"></a>00332 <span class="preprocessor"> if((uint32_t)(c)<=0xffff) { \</span> <a name="l00333"></a>00333 <span class="preprocessor"> (s)[(i)++]=(uint8_t)(((c)>>12)|0xe0); \</span> <a name="l00334"></a>00334 <span class="preprocessor"> } else { \</span> <a name="l00335"></a>00335 <span class="preprocessor"> (s)[(i)++]=(uint8_t)(((c)>>18)|0xf0); \</span> <a name="l00336"></a>00336 <span class="preprocessor"> (s)[(i)++]=(uint8_t)((((c)>>12)&0x3f)|0x80); \</span> <a name="l00337"></a>00337 <span class="preprocessor"> } \</span> <a name="l00338"></a>00338 <span class="preprocessor"> (s)[(i)++]=(uint8_t)((((c)>>6)&0x3f)|0x80); \</span> <a name="l00339"></a>00339 <span class="preprocessor"> } \</span> <a name="l00340"></a>00340 <span class="preprocessor"> (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \</span> <a name="l00341"></a>00341 <span class="preprocessor"> } \</span> <a name="l00342"></a>00342 <span class="preprocessor">}</span> <a name="l00343"></a>00343 <span class="preprocessor"></span> <a name="l00361"></a><a class="code" href="utf8_8h.html#a8a013997e3d13c501ce73bc45e662881">00361</a> <span class="preprocessor">#define U8_APPEND(s, i, capacity, c, isError) { \</span> <a name="l00362"></a>00362 <span class="preprocessor"> if((uint32_t)(c)<=0x7f) { \</span> <a name="l00363"></a>00363 <span class="preprocessor"> (s)[(i)++]=(uint8_t)(c); \</span> <a name="l00364"></a>00364 <span class="preprocessor"> } else if((uint32_t)(c)<=0x7ff && (i)+1<(capacity)) { \</span> <a name="l00365"></a>00365 <span class="preprocessor"> (s)[(i)++]=(uint8_t)(((c)>>6)|0xc0); \</span> <a name="l00366"></a>00366 <span class="preprocessor"> (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \</span> <a name="l00367"></a>00367 <span class="preprocessor"> } else if((uint32_t)(c)<=0xd7ff && (i)+2<(capacity)) { \</span> <a name="l00368"></a>00368 <span class="preprocessor"> (s)[(i)++]=(uint8_t)(((c)>>12)|0xe0); \</span> <a name="l00369"></a>00369 <span class="preprocessor"> (s)[(i)++]=(uint8_t)((((c)>>6)&0x3f)|0x80); \</span> <a name="l00370"></a>00370 <span class="preprocessor"> (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \</span> <a name="l00371"></a>00371 <span class="preprocessor"> } else { \</span> <a name="l00372"></a>00372 <span class="preprocessor"> (i)=utf8_appendCharSafeBody(s, (int32_t)(i), (int32_t)(capacity), c, &(isError)); \</span> <a name="l00373"></a>00373 <span class="preprocessor"> } \</span> <a name="l00374"></a>00374 <span class="preprocessor">}</span> <a name="l00375"></a>00375 <span class="preprocessor"></span> <a name="l00386"></a><a class="code" href="utf8_8h.html#a64a8113aea2125f806cbf5d77294b3cd">00386</a> <span class="preprocessor">#define U8_FWD_1_UNSAFE(s, i) { \</span> <a name="l00387"></a>00387 <span class="preprocessor"> (i)+=1+U8_COUNT_TRAIL_BYTES((s)[i]); \</span> <a name="l00388"></a>00388 <span class="preprocessor">}</span> <a name="l00389"></a>00389 <span class="preprocessor"></span> <a name="l00401"></a><a class="code" href="utf8_8h.html#a6d4c94e845b059fddba0c51e9bad87fd">00401</a> <span class="preprocessor">#define U8_FWD_1(s, i, length) { \</span> <a name="l00402"></a>00402 <span class="preprocessor"> uint8_t __b=(uint8_t)(s)[(i)++]; \</span> <a name="l00403"></a>00403 <span class="preprocessor"> if(U8_IS_LEAD(__b)) { \</span> <a name="l00404"></a>00404 <span class="preprocessor"> uint8_t __count=U8_COUNT_TRAIL_BYTES(__b); \</span> <a name="l00405"></a>00405 <span class="preprocessor"> if((i)+__count>(length)) { \</span> <a name="l00406"></a>00406 <span class="preprocessor"> __count=(uint8_t)((length)-(i)); \</span> <a name="l00407"></a>00407 <span class="preprocessor"> } \</span> <a name="l00408"></a>00408 <span class="preprocessor"> while(__count>0 && U8_IS_TRAIL((s)[i])) { \</span> <a name="l00409"></a>00409 <span class="preprocessor"> ++(i); \</span> <a name="l00410"></a>00410 <span class="preprocessor"> --__count; \</span> <a name="l00411"></a>00411 <span class="preprocessor"> } \</span> <a name="l00412"></a>00412 <span class="preprocessor"> } \</span> <a name="l00413"></a>00413 <span class="preprocessor">}</span> <a name="l00414"></a>00414 <span class="preprocessor"></span> <a name="l00427"></a><a class="code" href="utf8_8h.html#a8e8b4218834110431798cc84a0a664ae">00427</a> <span class="preprocessor">#define U8_FWD_N_UNSAFE(s, i, n) { \</span> <a name="l00428"></a>00428 <span class="preprocessor"> int32_t __N=(n); \</span> <a name="l00429"></a>00429 <span class="preprocessor"> while(__N>0) { \</span> <a name="l00430"></a>00430 <span class="preprocessor"> U8_FWD_1_UNSAFE(s, i); \</span> <a name="l00431"></a>00431 <span class="preprocessor"> --__N; \</span> <a name="l00432"></a>00432 <span class="preprocessor"> } \</span> <a name="l00433"></a>00433 <span class="preprocessor">}</span> <a name="l00434"></a>00434 <span class="preprocessor"></span> <a name="l00448"></a><a class="code" href="utf8_8h.html#a9a311dc48b8aa1050345b886adabf213">00448</a> <span class="preprocessor">#define U8_FWD_N(s, i, length, n) { \</span> <a name="l00449"></a>00449 <span class="preprocessor"> int32_t __N=(n); \</span> <a name="l00450"></a>00450 <span class="preprocessor"> while(__N>0 && (i)<(length)) { \</span> <a name="l00451"></a>00451 <span class="preprocessor"> U8_FWD_1(s, i, length); \</span> <a name="l00452"></a>00452 <span class="preprocessor"> --__N; \</span> <a name="l00453"></a>00453 <span class="preprocessor"> } \</span> <a name="l00454"></a>00454 <span class="preprocessor">}</span> <a name="l00455"></a>00455 <span class="preprocessor"></span> <a name="l00469"></a><a class="code" href="utf8_8h.html#ac46a385dbf64c97337522e1d1875a57e">00469</a> <span class="preprocessor">#define U8_SET_CP_START_UNSAFE(s, i) { \</span> <a name="l00470"></a>00470 <span class="preprocessor"> while(U8_IS_TRAIL((s)[i])) { --(i); } \</span> <a name="l00471"></a>00471 <span class="preprocessor">}</span> <a name="l00472"></a>00472 <span class="preprocessor"></span> <a name="l00487"></a><a class="code" href="utf8_8h.html#aa6d33627a8a5420a8f61e50da2aeca2a">00487</a> <span class="preprocessor">#define U8_SET_CP_START(s, start, i) { \</span> <a name="l00488"></a>00488 <span class="preprocessor"> if(U8_IS_TRAIL((s)[(i)])) { \</span> <a name="l00489"></a>00489 <span class="preprocessor"> (i)=utf8_back1SafeBody(s, start, (int32_t)(i)); \</span> <a name="l00490"></a>00490 <span class="preprocessor"> } \</span> <a name="l00491"></a>00491 <span class="preprocessor">}</span> <a name="l00492"></a>00492 <span class="preprocessor"></span> <a name="l00493"></a>00493 <span class="comment">/* definitions with backward iteration -------------------------------------- */</span> <a name="l00494"></a>00494 <a name="l00514"></a><a class="code" href="utf8_8h.html#a5f78eb19a6b25f61dccbae45d6ecf955">00514</a> <span class="preprocessor">#define U8_PREV_UNSAFE(s, i, c) { \</span> <a name="l00515"></a>00515 <span class="preprocessor"> (c)=(uint8_t)(s)[--(i)]; \</span> <a name="l00516"></a>00516 <span class="preprocessor"> if(U8_IS_TRAIL(c)) { \</span> <a name="l00517"></a>00517 <span class="preprocessor"> uint8_t __b, __count=1, __shift=6; \</span> <a name="l00518"></a>00518 <span class="preprocessor">\</span> <a name="l00519"></a>00519 <span class="preprocessor"> </span><span class="comment">/* c is a trail byte */</span> \ <a name="l00520"></a>00520 (c)&=0x3f; \ <a name="l00521"></a>00521 for(;;) { \ <a name="l00522"></a>00522 __b=(uint8_t)(s)[--(i)]; \ <a name="l00523"></a>00523 if(__b>=0xc0) { \ <a name="l00524"></a>00524 U8_MASK_LEAD_BYTE(__b, __count); \ <a name="l00525"></a>00525 (c)|=(UChar32)__b<<__shift; \ <a name="l00526"></a>00526 break; \ <a name="l00527"></a>00527 } else { \ <a name="l00528"></a>00528 (c)|=(UChar32)(__b&0x3f)<<__shift; \ <a name="l00529"></a>00529 ++__count; \ <a name="l00530"></a>00530 __shift+=6; \ <a name="l00531"></a>00531 } \ <a name="l00532"></a>00532 } \ <a name="l00533"></a>00533 } \ <a name="l00534"></a>00534 } <a name="l00535"></a>00535 <a name="l00556"></a><a class="code" href="utf8_8h.html#a17287c1f01ce84fdf8852a756643b076">00556</a> <span class="preprocessor">#define U8_PREV(s, start, i, c) { \</span> <a name="l00557"></a>00557 <span class="preprocessor"> (c)=(uint8_t)(s)[--(i)]; \</span> <a name="l00558"></a>00558 <span class="preprocessor"> if((c)>=0x80) { \</span> <a name="l00559"></a>00559 <span class="preprocessor"> if((c)<=0xbf) { \</span> <a name="l00560"></a>00560 <span class="preprocessor"> (c)=utf8_prevCharSafeBody((const uint8_t *)s, start, &(i), c, -1); \</span> <a name="l00561"></a>00561 <span class="preprocessor"> } else { \</span> <a name="l00562"></a>00562 <span class="preprocessor"> (c)=U_SENTINEL; \</span> <a name="l00563"></a>00563 <span class="preprocessor"> } \</span> <a name="l00564"></a>00564 <span class="preprocessor"> } \</span> <a name="l00565"></a>00565 <span class="preprocessor">}</span> <a name="l00566"></a>00566 <span class="preprocessor"></span> <a name="l00578"></a><a class="code" href="utf8_8h.html#a3969beb6252f8605ab678990c8af2f48">00578</a> <span class="preprocessor">#define U8_BACK_1_UNSAFE(s, i) { \</span> <a name="l00579"></a>00579 <span class="preprocessor"> while(U8_IS_TRAIL((s)[--(i)])) {} \</span> <a name="l00580"></a>00580 <span class="preprocessor">}</span> <a name="l00581"></a>00581 <span class="preprocessor"></span> <a name="l00594"></a><a class="code" href="utf8_8h.html#adac4ee359e6233cb2990b1047fd5be3c">00594</a> <span class="preprocessor">#define U8_BACK_1(s, start, i) { \</span> <a name="l00595"></a>00595 <span class="preprocessor"> if(U8_IS_TRAIL((s)[--(i)])) { \</span> <a name="l00596"></a>00596 <span class="preprocessor"> (i)=utf8_back1SafeBody(s, start, (int32_t)(i)); \</span> <a name="l00597"></a>00597 <span class="preprocessor"> } \</span> <a name="l00598"></a>00598 <span class="preprocessor">}</span> <a name="l00599"></a>00599 <span class="preprocessor"></span> <a name="l00613"></a><a class="code" href="utf8_8h.html#aa36f62ea4ac87362e376e4cbea10098d">00613</a> <span class="preprocessor">#define U8_BACK_N_UNSAFE(s, i, n) { \</span> <a name="l00614"></a>00614 <span class="preprocessor"> int32_t __N=(n); \</span> <a name="l00615"></a>00615 <span class="preprocessor"> while(__N>0) { \</span> <a name="l00616"></a>00616 <span class="preprocessor"> U8_BACK_1_UNSAFE(s, i); \</span> <a name="l00617"></a>00617 <span class="preprocessor"> --__N; \</span> <a name="l00618"></a>00618 <span class="preprocessor"> } \</span> <a name="l00619"></a>00619 <span class="preprocessor">}</span> <a name="l00620"></a>00620 <span class="preprocessor"></span> <a name="l00635"></a><a class="code" href="utf8_8h.html#ab0ce585952c8ba4b103fb6b7aea801ba">00635</a> <span class="preprocessor">#define U8_BACK_N(s, start, i, n) { \</span> <a name="l00636"></a>00636 <span class="preprocessor"> int32_t __N=(n); \</span> <a name="l00637"></a>00637 <span class="preprocessor"> while(__N>0 && (i)>(start)) { \</span> <a name="l00638"></a>00638 <span class="preprocessor"> U8_BACK_1(s, start, i); \</span> <a name="l00639"></a>00639 <span class="preprocessor"> --__N; \</span> <a name="l00640"></a>00640 <span class="preprocessor"> } \</span> <a name="l00641"></a>00641 <span class="preprocessor">}</span> <a name="l00642"></a>00642 <span class="preprocessor"></span> <a name="l00656"></a><a class="code" href="utf8_8h.html#a910ba47de6d82fafc25b5e12f3a68588">00656</a> <span class="preprocessor">#define U8_SET_CP_LIMIT_UNSAFE(s, i) { \</span> <a name="l00657"></a>00657 <span class="preprocessor"> U8_BACK_1_UNSAFE(s, i); \</span> <a name="l00658"></a>00658 <span class="preprocessor"> U8_FWD_1_UNSAFE(s, i); \</span> <a name="l00659"></a>00659 <span class="preprocessor">}</span> <a name="l00660"></a>00660 <span class="preprocessor"></span> <a name="l00676"></a><a class="code" href="utf8_8h.html#a40fe523809a3a4e647e47513336b81d9">00676</a> <span class="preprocessor">#define U8_SET_CP_LIMIT(s, start, i, length) { \</span> <a name="l00677"></a>00677 <span class="preprocessor"> if((start)<(i) && (i)<(length)) { \</span> <a name="l00678"></a>00678 <span class="preprocessor"> U8_BACK_1(s, start, i); \</span> <a name="l00679"></a>00679 <span class="preprocessor"> U8_FWD_1(s, i, length); \</span> <a name="l00680"></a>00680 <span class="preprocessor"> } \</span> <a name="l00681"></a>00681 <span class="preprocessor">}</span> <a name="l00682"></a>00682 <span class="preprocessor"></span> <a name="l00683"></a>00683 <span class="preprocessor">#endif</span> </pre></div></div> <!--- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Defines</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <hr class="footer"/><address style="text-align: right;"><small>Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2-20100208 </small></address> </body> </html>