<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Crystal Space 1.2.1: csutil/csuctransform.h Source File (Crystal Space 1.2.1 Public API Reference)</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <table border="0" cellpadding="0" cellspacing="0" width="100%" class="head"> <tr height="59"> <td class="head" width="202" valign="bottom" style="padding-left:0;"><a href="http://www.crystalspace3d.org/"><img src="csblur.png" width="236" height="59" alt="CrystalSpace" border="0"></a></td> <td class="head"><h2>Public API Reference</h2></td> </tr> <tr height="11"> <td colspan="2" class="headshadow" valign="top" style="padding-left:0;"><img src="csblurb.png" width="236" height="11" alt="" border="0"></td> </tr> </table> <div class="content"> <!-- Generated by Doxygen 1.5.3 --> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul> </div> <h1>csutil/csuctransform.h</h1><a href="csuctransform_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"> Copyright (C) 2003 by Frank Richter</span> <a name="l00003"></a>00003 <span class="comment"></span> <a name="l00004"></a>00004 <span class="comment"> This library is free software; you can redistribute it and/or</span> <a name="l00005"></a>00005 <span class="comment"> modify it under the terms of the GNU Library General Public</span> <a name="l00006"></a>00006 <span class="comment"> License as published by the Free Software Foundation; either</span> <a name="l00007"></a>00007 <span class="comment"> version 2 of the License, or (at your option) any later version.</span> <a name="l00008"></a>00008 <span class="comment"></span> <a name="l00009"></a>00009 <span class="comment"> This library is distributed in the hope that it will be useful,</span> <a name="l00010"></a>00010 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00011"></a>00011 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00012"></a>00012 <span class="comment"> Library General Public License for more details.</span> <a name="l00013"></a>00013 <span class="comment"></span> <a name="l00014"></a>00014 <span class="comment"> You should have received a copy of the GNU Library General Public</span> <a name="l00015"></a>00015 <span class="comment"> License along with this library; if not, write to the Free</span> <a name="l00016"></a>00016 <span class="comment"> Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span> <a name="l00017"></a>00017 <span class="comment">*/</span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="preprocessor">#ifndef __CS_CSUCTRANSFORM_H__</span> <a name="l00020"></a>00020 <span class="preprocessor"></span><span class="preprocessor">#define __CS_CSUCTRANSFORM_H__</span> <a name="l00021"></a>00021 <span class="preprocessor"></span> <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="csunicode_8h.html" title="Unicode types and macros.">csunicode.h</a>"</span> <a name="l00023"></a>00023 <a name="l00035"></a><a class="code" href="group__util.html#g2284bf3a9015a6efbdbc213a33ec1333">00035</a> <span class="preprocessor">#define CS_UC_MAX_UTF8_ENCODED 4 </span><span class="comment">/* 6 to encode 32 bit */</span> <a name="l00036"></a>00036 <a name="l00040"></a><a class="code" href="group__util.html#g054b00c409694434d6f9623a8ecd8326">00040</a> <span class="preprocessor">#define CS_UC_MAX_UTF16_ENCODED 2</span> <a name="l00041"></a>00041 <span class="preprocessor"></span> <a name="l00045"></a><a class="code" href="group__util.html#gabfc86cd4c0627a3a08cbb7eb97575de">00045</a> <span class="preprocessor">#define CS_UC_MAX_UTF32_ENCODED 1</span> <a name="l00046"></a>00046 <span class="preprocessor"></span><span class="preprocessor">#if (CS_WCHAR_T_SIZE == 1)</span> <a name="l00047"></a>00047 <span class="preprocessor"></span><span class="preprocessor">#define CS_UC_MAX_WCHAR_T_ENCODED CS_UC_MAX_UTF8_ENCODED</span> <a name="l00048"></a>00048 <span class="preprocessor"></span><span class="preprocessor">#elif (CS_WCHAR_T_SIZE == 2)</span> <a name="l00049"></a>00049 <span class="preprocessor"></span> <a name="l00053"></a>00053 <span class="preprocessor">#define CS_UC_MAX_WCHAR_T_ENCODED CS_UC_MAX_UTF16_ENCODED</span> <a name="l00054"></a>00054 <span class="preprocessor"></span><span class="preprocessor">#else</span> <a name="l00055"></a><a class="code" href="group__util.html#gd35001a319ee965133bc2ddcda05ea50">00055</a> <span class="preprocessor"></span><span class="preprocessor">#define CS_UC_MAX_WCHAR_T_ENCODED CS_UC_MAX_UTF32_ENCODED</span> <a name="l00056"></a>00056 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00057"></a>00057 <span class="preprocessor"></span> <a name="l00061"></a><a class="code" href="group__util.html#gc628cf133962dc01ae5085ab25031834">00061</a> <span class="preprocessor">#define CS_UC_MAX_MAPPED 3</span> <a name="l00062"></a>00062 <span class="preprocessor"></span> <a name="l00066"></a>00066 <span class="keyword">enum</span> <a name="l00067"></a>00067 { <a name="l00073"></a><a class="code" href="group__util.html#ggfccd240f973cf154952fb917c9209719502727b715dbfce568251bcf397ca4ca">00073</a> <a class="code" href="group__util.html#ggfccd240f973cf154952fb917c9209719502727b715dbfce568251bcf397ca4ca" title="Force &#39;simple&#39; mappings, that is, at most one code point is returned.">csUcMapSimple</a> = (1 << 0) <a name="l00074"></a>00074 }; <a name="l00075"></a>00075 <a name="l00079"></a><a class="code" href="classcsUnicodeTransform.html">00079</a> <span class="keyword">class </span>CS_CRYSTALSPACE_EXPORT <a class="code" href="classcsUnicodeTransform.html" title="Contains functions to convert between several UTF encodings.">csUnicodeTransform</a> <a name="l00080"></a>00080 { <a name="l00081"></a>00081 <span class="keyword">public</span>: <a name="l00082"></a><a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">00082</a> <span class="preprocessor">#define FAIL(ret) \</span> <a name="l00083"></a>00083 <span class="preprocessor"> { \</span> <a name="l00084"></a>00084 <span class="preprocessor"> if (isValid) *isValid = false; \</span> <a name="l00085"></a>00085 <span class="preprocessor"> ch = CS_UC_CHAR_REPLACER; \</span> <a name="l00086"></a>00086 <span class="preprocessor"> return ret; \</span> <a name="l00087"></a>00087 <span class="preprocessor"> }</span> <a name="l00088"></a>00088 <span class="preprocessor"></span> <a name="l00089"></a><a class="code" href="csuctransform_8h.html#82bc06cf44e2201df39aa76de6019980">00089</a> <span class="preprocessor">#define SUCCEED \</span> <a name="l00090"></a>00090 <span class="preprocessor"> if (isValid) *isValid = true; \</span> <a name="l00091"></a>00091 <span class="preprocessor"> return chUsed;</span> <a name="l00092"></a>00092 <span class="preprocessor"></span> <a name="l00093"></a><a class="code" href="csuctransform_8h.html#02601ccd5eed1adfa4fd22228efb3da0">00093</a> <span class="preprocessor">#define GET_NEXT(next) \</span> <a name="l00094"></a>00094 <span class="preprocessor"> if ((size_t)chUsed == strlen) \</span> <a name="l00095"></a>00095 <span class="preprocessor"> { \</span> <a name="l00096"></a>00096 <span class="preprocessor"> FAIL(chUsed); \</span> <a name="l00097"></a>00097 <span class="preprocessor"> } \</span> <a name="l00098"></a>00098 <span class="preprocessor"> next = *str++; \</span> <a name="l00099"></a>00099 <span class="preprocessor"> if (next == 0) \</span> <a name="l00100"></a>00100 <span class="preprocessor"> { \</span> <a name="l00101"></a>00101 <span class="preprocessor"> FAIL(chUsed); \</span> <a name="l00102"></a>00102 <span class="preprocessor"> } \</span> <a name="l00103"></a>00103 <span class="preprocessor"> chUsed++; </span> <a name="l00104"></a>00104 <span class="preprocessor"></span> <a name="l00123"></a><a class="code" href="classcsUnicodeTransform.html#21e5a75955302bbc73751a4dc459af54">00123</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> UTF8Decode (<span class="keyword">const</span> <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>* str, <span class="keywordtype">size_t</span> strlen, <a name="l00124"></a>00124 <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>& ch, <span class="keywordtype">bool</span>* isValid = 0, <span class="keywordtype">bool</span> returnNonChar = <span class="keyword">false</span>) <a name="l00125"></a>00125 { <a name="l00126"></a>00126 <span class="keywordflow">if</span> (str == 0) <a name="l00127"></a>00127 { <a name="l00128"></a>00128 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(0); <a name="l00129"></a>00129 } <a name="l00130"></a>00130 <span class="keywordtype">int</span> chUsed = 0; <a name="l00131"></a>00131 <a name="l00132"></a>00132 <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a> curCh; <a name="l00133"></a>00133 <a class="code" href="csuctransform_8h.html#02601ccd5eed1adfa4fd22228efb3da0">GET_NEXT</a>(curCh); <a name="l00134"></a>00134 <span class="keywordflow">if</span> ((curCh & 0x80) == 0) <a name="l00135"></a>00135 { <a name="l00136"></a>00136 <span class="comment">// easy case</span> <a name="l00137"></a>00137 ch = curCh; <a name="l00138"></a>00138 <a class="code" href="csuctransform_8h.html#82bc06cf44e2201df39aa76de6019980">SUCCEED</a>; <a name="l00139"></a>00139 } <a name="l00140"></a>00140 <span class="keywordflow">else</span> <a name="l00141"></a>00141 { <a name="l00142"></a>00142 <span class="comment">// Count with how many bytes this char is encoded.</span> <a name="l00143"></a>00143 <span class="keywordtype">int</span> n = 0; <a name="l00144"></a>00144 <span class="keywordflow">while</span> ((n < 7) && ((curCh & (1 << (7 - n))) != 0)) { n++; } <a name="l00145"></a>00145 <a name="l00146"></a>00146 <span class="keywordflow">if</span> ((n < 2) || (n > 6)) <a name="l00147"></a>00147 { <a name="l00148"></a>00148 <span class="comment">// Invalid code: first char of a "sequence" must have</span> <a name="l00149"></a>00149 <span class="comment">// at least two and at most six MSBs set</span> <a name="l00150"></a>00150 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(1); <a name="l00151"></a>00151 } <a name="l00152"></a>00152 <a name="l00153"></a>00153 ch = (curCh & ((1 << (8 - n)) - 1)); <a name="l00154"></a>00154 <a name="l00155"></a>00155 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i < n; i++) <a name="l00156"></a>00156 { <a name="l00157"></a>00157 <a class="code" href="csuctransform_8h.html#02601ccd5eed1adfa4fd22228efb3da0">GET_NEXT</a>(curCh); <a name="l00158"></a>00158 <span class="keywordflow">if</span> ((curCh & 0xc0) != 0x80) <a name="l00159"></a>00159 { <a name="l00160"></a>00160 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(chUsed); <a name="l00161"></a>00161 } <a name="l00162"></a>00162 <span class="keywordflow">else</span> <a name="l00163"></a>00163 { <a name="l00164"></a>00164 ch <<= 6; <a name="l00165"></a>00165 ch |= (curCh & 0x3f); <a name="l00166"></a>00166 } <a name="l00167"></a>00167 } <a name="l00168"></a>00168 <a name="l00169"></a>00169 <span class="comment">// Check if in Unicode range.</span> <a name="l00170"></a>00170 <span class="keywordflow">if</span> (ch > <a class="code" href="group__util.html#g5e76da15993612b523f18deee6e40186" title="Highest valid Unicode codepoint.">CS_UC_LAST_CHAR</a>) <a name="l00171"></a>00171 { <a name="l00172"></a>00172 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(chUsed); <a name="l00173"></a>00173 } <a name="l00174"></a>00174 <a name="l00175"></a>00175 <span class="comment">// Check for "overlong" codes.</span> <a name="l00176"></a>00176 <span class="keywordflow">if</span> ((ch < 0x80) && (n > 0)) <a name="l00177"></a>00177 { <a name="l00178"></a>00178 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(chUsed); <a name="l00179"></a>00179 } <a name="l00180"></a>00180 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((ch < 0x800) && (n > 2)) <a name="l00181"></a>00181 { <a name="l00182"></a>00182 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(chUsed); <a name="l00183"></a>00183 } <a name="l00184"></a>00184 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((ch < 0x10000) && (n > 3)) <a name="l00185"></a>00185 { <a name="l00186"></a>00186 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(chUsed); <a name="l00187"></a>00187 } <a name="l00188"></a>00188 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((ch < 0x200000) && (n > 4)) <a name="l00189"></a>00189 { <a name="l00190"></a>00190 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(chUsed); <a name="l00191"></a>00191 } <a name="l00192"></a>00192 <span class="comment">/* </span> <a name="l00193"></a>00193 <span class="comment"> else if ((ch < 0x4000000) && (n > 5))</span> <a name="l00194"></a>00194 <span class="comment"> {</span> <a name="l00195"></a>00195 <span class="comment"> FAIL(chUsed);</span> <a name="l00196"></a>00196 <span class="comment"> }</span> <a name="l00197"></a>00197 <span class="comment"> else if ((ch < 0x80000000) && (n > 6))</span> <a name="l00198"></a>00198 <span class="comment"> {</span> <a name="l00199"></a>00199 <span class="comment"> FAIL(chUsed);</span> <a name="l00200"></a>00200 <span class="comment"> }</span> <a name="l00201"></a>00201 <span class="comment"> */</span> <a name="l00202"></a>00202 <a name="l00203"></a>00203 <span class="keywordflow">if</span> (!returnNonChar && (<a class="code" href="group__util.html#gaa6e26882081c80c2723dec47e5afdb3" title="Test whether a code point is a Unicode noncharacter.">CS_UC_IS_NONCHARACTER</a>(ch) <a name="l00204"></a>00204 || <a class="code" href="group__util.html#g506d88b895df510ebcffba6d5acab4ac" title="Check whether a code is in the &quot;high&quot; or &quot;low surrogate&quot; range...">CS_UC_IS_SURROGATE</a>(ch))) <a name="l00205"></a>00205 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(chUsed); <a name="l00206"></a>00206 <a class="code" href="csuctransform_8h.html#82bc06cf44e2201df39aa76de6019980">SUCCEED</a>; <a name="l00207"></a>00207 } <a name="l00208"></a>00208 } <a name="l00209"></a>00209 <a name="l00214"></a><a class="code" href="classcsUnicodeTransform.html#723ec7aa6c1ef41e28f56f26a2ead1c9">00214</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> UTF16Decode (<span class="keyword">const</span> <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>* str, <span class="keywordtype">size_t</span> strlen, <a name="l00215"></a>00215 <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>& ch, <span class="keywordtype">bool</span>* isValid = 0, <span class="keywordtype">bool</span> returnNonChar = <span class="keyword">false</span>) <a name="l00216"></a>00216 { <a name="l00217"></a>00217 <span class="keywordflow">if</span> (str == 0) <a name="l00218"></a>00218 { <a name="l00219"></a>00219 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(0); <a name="l00220"></a>00220 } <a name="l00221"></a>00221 <span class="keywordtype">int</span> chUsed = 0; <a name="l00222"></a>00222 <a name="l00223"></a>00223 <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a> curCh; <a name="l00224"></a>00224 <a class="code" href="csuctransform_8h.html#02601ccd5eed1adfa4fd22228efb3da0">GET_NEXT</a>(curCh); <a name="l00225"></a>00225 <span class="comment">// Decode surrogate</span> <a name="l00226"></a>00226 <span class="keywordflow">if</span> (<a class="code" href="group__util.html#g506d88b895df510ebcffba6d5acab4ac" title="Check whether a code is in the &quot;high&quot; or &quot;low surrogate&quot; range...">CS_UC_IS_SURROGATE</a> (curCh)) <a name="l00227"></a>00227 { <a name="l00228"></a>00228 <span class="comment">// Invalid code</span> <a name="l00229"></a>00229 <span class="keywordflow">if</span> (!<a class="code" href="group__util.html#gc8cdcb503070d89ec9b289a26925743e" title="Check whether a code is in the &quot;high surrogate&quot; range.">CS_UC_IS_HIGH_SURROGATE</a> (curCh)) <a name="l00230"></a>00230 { <a name="l00231"></a>00231 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(chUsed); <a name="l00232"></a>00232 } <a name="l00233"></a>00233 ch = 0x10000 + ((curCh & 0x03ff) << 10); <a name="l00234"></a>00234 <a class="code" href="csuctransform_8h.html#02601ccd5eed1adfa4fd22228efb3da0">GET_NEXT</a>(curCh); <a name="l00235"></a>00235 <span class="comment">// Invalid code</span> <a name="l00236"></a>00236 <span class="keywordflow">if</span> (!<a class="code" href="group__util.html#gd381d5d932e71207fc276acbfaa972f5" title="Check whether a code is in the &quot;low surrogate&quot; range.">CS_UC_IS_LOW_SURROGATE</a> (curCh)) <a name="l00237"></a>00237 { <a name="l00238"></a>00238 <span class="comment">// Fail with 1 so the char is handled upon the next Decode.</span> <a name="l00239"></a>00239 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(1); <a name="l00240"></a>00240 } <a name="l00241"></a>00241 ch |= (curCh & 0x3ff); <a name="l00242"></a>00242 } <a name="l00243"></a>00243 <span class="keywordflow">else</span> <a name="l00244"></a>00244 { <a name="l00245"></a>00245 ch = curCh; <a name="l00246"></a>00246 } <a name="l00247"></a>00247 <span class="keywordflow">if</span> (!returnNonChar && (<a class="code" href="group__util.html#gaa6e26882081c80c2723dec47e5afdb3" title="Test whether a code point is a Unicode noncharacter.">CS_UC_IS_NONCHARACTER</a>(ch) <a name="l00248"></a>00248 || <a class="code" href="group__util.html#g506d88b895df510ebcffba6d5acab4ac" title="Check whether a code is in the &quot;high&quot; or &quot;low surrogate&quot; range...">CS_UC_IS_SURROGATE</a>(ch))) <a name="l00249"></a>00249 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(chUsed); <a name="l00250"></a>00250 <a class="code" href="csuctransform_8h.html#82bc06cf44e2201df39aa76de6019980">SUCCEED</a>; <a name="l00251"></a>00251 } <a name="l00252"></a>00252 <a name="l00257"></a><a class="code" href="classcsUnicodeTransform.html#cac90f99a50393c4a81e5b9912ac6b74">00257</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> UTF32Decode (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* str, <span class="keywordtype">size_t</span> strlen, <a name="l00258"></a>00258 <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>& ch, <span class="keywordtype">bool</span>* isValid = 0, <span class="keywordtype">bool</span> returnNonChar = <span class="keyword">false</span>) <a name="l00259"></a>00259 { <a name="l00260"></a>00260 <span class="keywordflow">if</span> (str == 0) <a name="l00261"></a>00261 { <a name="l00262"></a>00262 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(0); <a name="l00263"></a>00263 } <a name="l00264"></a>00264 <span class="keywordtype">int</span> chUsed = 0; <a name="l00265"></a>00265 <a name="l00266"></a>00266 <a class="code" href="csuctransform_8h.html#02601ccd5eed1adfa4fd22228efb3da0">GET_NEXT</a>(ch); <a name="l00267"></a>00267 <span class="keywordflow">if</span> ((!returnNonChar && (<a class="code" href="group__util.html#gaa6e26882081c80c2723dec47e5afdb3" title="Test whether a code point is a Unicode noncharacter.">CS_UC_IS_NONCHARACTER</a>(ch) <a name="l00268"></a>00268 || <a class="code" href="group__util.html#g506d88b895df510ebcffba6d5acab4ac" title="Check whether a code is in the &quot;high&quot; or &quot;low surrogate&quot; range...">CS_UC_IS_SURROGATE</a>(ch))) || (ch > <a class="code" href="group__util.html#g5e76da15993612b523f18deee6e40186" title="Highest valid Unicode codepoint.">CS_UC_LAST_CHAR</a>)) <a name="l00269"></a>00269 <a class="code" href="csuctransform_8h.html#63e0c1f08ddfa85e3b7e3c3176c040d8">FAIL</a>(chUsed); <a name="l00270"></a>00270 <a class="code" href="csuctransform_8h.html#82bc06cf44e2201df39aa76de6019980">SUCCEED</a>; <a name="l00271"></a>00271 } <a name="l00272"></a>00272 <a name="l00277"></a><a class="code" href="classcsUnicodeTransform.html#24c171b2e92da381499801aba4422106">00277</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> Decode (<span class="keyword">const</span> <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>* str, <span class="keywordtype">size_t</span> strlen, <a name="l00278"></a>00278 <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>& ch, <span class="keywordtype">bool</span>* isValid = 0, <span class="keywordtype">bool</span> returnNonChar = <span class="keyword">false</span>) <a name="l00279"></a>00279 { <a name="l00280"></a>00280 <span class="keywordflow">return</span> UTF8Decode (str, strlen, ch, isValid, returnNonChar); <a name="l00281"></a>00281 } <a name="l00286"></a><a class="code" href="classcsUnicodeTransform.html#4971c5f03f1f54f945e002458162bc2d">00286</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> Decode (<span class="keyword">const</span> <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>* str, <span class="keywordtype">size_t</span> strlen, <a name="l00287"></a>00287 <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>& ch, <span class="keywordtype">bool</span>* isValid = 0, <span class="keywordtype">bool</span> returnNonChar = <span class="keyword">false</span>) <a name="l00288"></a>00288 { <a name="l00289"></a>00289 <span class="keywordflow">return</span> UTF16Decode (str, strlen, ch, isValid, returnNonChar); <a name="l00290"></a>00290 } <a name="l00295"></a><a class="code" href="classcsUnicodeTransform.html#d069d0d41c21b04b2e62edb83c3cbac3">00295</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> Decode (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* str, <span class="keywordtype">size_t</span> strlen, <a name="l00296"></a>00296 <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>& ch, <span class="keywordtype">bool</span>* isValid = 0, <span class="keywordtype">bool</span> returnNonChar = <span class="keyword">false</span>) <a name="l00297"></a>00297 { <a name="l00298"></a>00298 <span class="keywordflow">return</span> UTF32Decode (str, strlen, ch, isValid, returnNonChar); <a name="l00299"></a>00299 } <a name="l00300"></a>00300 <a name="l00302"></a>00302 <span class="preprocessor">#undef FAIL</span> <a name="l00303"></a>00303 <span class="preprocessor"></span><span class="preprocessor">#undef SUCCEED</span> <a name="l00304"></a>00304 <span class="preprocessor"></span><span class="preprocessor">#undef GET_NEXT</span> <a name="l00305"></a>00305 <span class="preprocessor"></span> <a name="l00308"></a><a class="code" href="csuctransform_8h.html#95379146c23b14d697233d8c7ca1b0fa">00308</a> <span class="preprocessor">#define _OUTPUT_CHAR(buf, chr) \</span> <a name="l00309"></a>00309 <span class="preprocessor"> if (bufRemaining > 0) \</span> <a name="l00310"></a>00310 <span class="preprocessor"> { \</span> <a name="l00311"></a>00311 <span class="preprocessor"> if(buf) *buf++ = chr; \</span> <a name="l00312"></a>00312 <span class="preprocessor"> bufRemaining--; \</span> <a name="l00313"></a>00313 <span class="preprocessor"> } \</span> <a name="l00314"></a>00314 <span class="preprocessor"> encodedLen++;</span> <a name="l00315"></a>00315 <span class="preprocessor"></span> <a name="l00316"></a>00316 <span class="preprocessor">#define OUTPUT_CHAR(chr) _OUTPUT_CHAR(buf, chr)</span> <a name="l00317"></a>00317 <span class="preprocessor"></span> <a name="l00333"></a><a class="code" href="classcsUnicodeTransform.html#ea53afe26677ed7575661735e3087075">00333</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> EncodeUTF8 (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> ch, <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>* buf, <a name="l00334"></a>00334 <span class="keywordtype">size_t</span> bufsize, <span class="keywordtype">bool</span> allowNonchars = <span class="keyword">false</span>) <a name="l00335"></a>00335 { <a name="l00336"></a>00336 <span class="keywordflow">if</span> ((!allowNonchars && ((<a class="code" href="group__util.html#gaa6e26882081c80c2723dec47e5afdb3" title="Test whether a code point is a Unicode noncharacter.">CS_UC_IS_NONCHARACTER</a>(ch)) <a name="l00337"></a>00337 || (<a class="code" href="group__util.html#g506d88b895df510ebcffba6d5acab4ac" title="Check whether a code is in the &quot;high&quot; or &quot;low surrogate&quot; range...">CS_UC_IS_SURROGATE</a>(ch)))) || (ch > <a class="code" href="group__util.html#g5e76da15993612b523f18deee6e40186" title="Highest valid Unicode codepoint.">CS_UC_LAST_CHAR</a>)) <a name="l00338"></a>00338 <span class="keywordflow">return</span> 0; <a name="l00339"></a>00339 <span class="keywordtype">size_t</span> bufRemaining = bufsize; <a name="l00340"></a>00340 <span class="keywordtype">int</span> encodedLen = 0; <a name="l00341"></a>00341 <a name="l00342"></a>00342 <span class="keywordflow">if</span> (ch < 0x80) <a name="l00343"></a>00343 { <a name="l00344"></a>00344 <a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">OUTPUT_CHAR</a> ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>)ch); <a name="l00345"></a>00345 } <a name="l00346"></a>00346 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ch < 0x800) <a name="l00347"></a>00347 { <a name="l00348"></a>00348 <a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">OUTPUT_CHAR</a> ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>)(0xc0 | (ch >> 6))); <a name="l00349"></a>00349 <a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">OUTPUT_CHAR</a> ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>)(0x80 | (ch & 0x3f))); <a name="l00350"></a>00350 } <a name="l00351"></a>00351 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ch < 0x10000) <a name="l00352"></a>00352 { <a name="l00353"></a>00353 <a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">OUTPUT_CHAR</a> ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>)(0xe0 | (ch >> 12))); <a name="l00354"></a>00354 <a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">OUTPUT_CHAR</a> ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>)(0x80 | ((ch >> 6) & 0x3f))); <a name="l00355"></a>00355 <a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">OUTPUT_CHAR</a> ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>)(0x80 | (ch & 0x3f))); <a name="l00356"></a>00356 } <a name="l00357"></a>00357 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ch < 0x200000) <a name="l00358"></a>00358 { <a name="l00359"></a>00359 <a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">OUTPUT_CHAR</a> ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>)(0xf0 | (ch >> 18))); <a name="l00360"></a>00360 <a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">OUTPUT_CHAR</a> ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>)(0x80 | ((ch >> 12) & 0x3f))); <a name="l00361"></a>00361 <a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">OUTPUT_CHAR</a> ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>)(0x80 | ((ch >> 6) & 0x3f))); <a name="l00362"></a>00362 <a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">OUTPUT_CHAR</a> ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>)(0x80 | (ch & 0x3f))); <a name="l00363"></a>00363 } <a name="l00364"></a>00364 <span class="comment">/*</span> <a name="l00365"></a>00365 <span class="comment"> else if (ch < 0x4000000)</span> <a name="l00366"></a>00366 <span class="comment"> {</span> <a name="l00367"></a>00367 <span class="comment"> OUTPUT_CHAR ((utf8_char)(0xf8 | (ch >> 24)));</span> <a name="l00368"></a>00368 <span class="comment"> OUTPUT_CHAR ((utf8_char)(0x80 | ((ch >> 18) & 0x3f)));</span> <a name="l00369"></a>00369 <span class="comment"> OUTPUT_CHAR ((utf8_char)(0x80 | ((ch >> 12) & 0x3f)));</span> <a name="l00370"></a>00370 <span class="comment"> OUTPUT_CHAR ((utf8_char)(0x80 | ((ch >> 6) & 0x3f)));</span> <a name="l00371"></a>00371 <span class="comment"> OUTPUT_CHAR ((utf8_char)(0x80 | (ch & 0x3f)));</span> <a name="l00372"></a>00372 <span class="comment"> }</span> <a name="l00373"></a>00373 <span class="comment"> else if (ch < 0x80000000)</span> <a name="l00374"></a>00374 <span class="comment"> {</span> <a name="l00375"></a>00375 <span class="comment"> OUTPUT_CHAR ((utf8_char)(0xfc | (ch >> 30)));</span> <a name="l00376"></a>00376 <span class="comment"> OUTPUT_CHAR ((utf8_char)(0x80 | ((ch >> 24) & 0x3f)));</span> <a name="l00377"></a>00377 <span class="comment"> OUTPUT_CHAR ((utf8_char)(0x80 | ((ch >> 18) & 0x3f)));</span> <a name="l00378"></a>00378 <span class="comment"> OUTPUT_CHAR ((utf8_char)(0x80 | ((ch >> 12) & 0x3f)));</span> <a name="l00379"></a>00379 <span class="comment"> OUTPUT_CHAR ((utf8_char)(0x80 | ((ch >> 6) & 0x3f)));</span> <a name="l00380"></a>00380 <span class="comment"> OUTPUT_CHAR ((utf8_char)(0x80 | (ch & 0x3f)));</span> <a name="l00381"></a>00381 <span class="comment"> }</span> <a name="l00382"></a>00382 <span class="comment"> */</span> <a name="l00383"></a>00383 <span class="keywordflow">return</span> encodedLen; <a name="l00384"></a>00384 } <a name="l00385"></a>00385 <a name="l00401"></a><a class="code" href="classcsUnicodeTransform.html#3dbb184083e5ddf867cbb2ff787b08ac">00401</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> EncodeUTF16 (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> ch, <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>* buf, <a name="l00402"></a>00402 <span class="keywordtype">size_t</span> bufsize, <span class="keywordtype">bool</span> allowNonchars = <span class="keyword">false</span>) <a name="l00403"></a>00403 { <a name="l00404"></a>00404 <span class="keywordflow">if</span> ((!allowNonchars && ((<a class="code" href="group__util.html#gaa6e26882081c80c2723dec47e5afdb3" title="Test whether a code point is a Unicode noncharacter.">CS_UC_IS_NONCHARACTER</a>(ch)) <a name="l00405"></a>00405 || (<a class="code" href="group__util.html#g506d88b895df510ebcffba6d5acab4ac" title="Check whether a code is in the &quot;high&quot; or &quot;low surrogate&quot; range...">CS_UC_IS_SURROGATE</a>(ch)))) || (ch > <a class="code" href="group__util.html#g5e76da15993612b523f18deee6e40186" title="Highest valid Unicode codepoint.">CS_UC_LAST_CHAR</a>)) <a name="l00406"></a>00406 <span class="keywordflow">return</span> 0; <a name="l00407"></a>00407 <span class="keywordtype">size_t</span> bufRemaining = bufsize; <a name="l00408"></a>00408 <span class="keywordtype">int</span> encodedLen = 0; <a name="l00409"></a>00409 <a name="l00410"></a>00410 <span class="keywordflow">if</span> (ch < 0x10000) <a name="l00411"></a>00411 { <a name="l00412"></a>00412 <a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">OUTPUT_CHAR</a>((<a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>)ch); <a name="l00413"></a>00413 } <a name="l00414"></a>00414 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ch < 0x100000) <a name="l00415"></a>00415 { <a name="l00416"></a>00416 <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> ch_shifted = ch - 0x10000; <a name="l00417"></a>00417 <a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">OUTPUT_CHAR</a>((<a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>)((ch_shifted >> 10) <a name="l00418"></a>00418 | <a class="code" href="group__util.html#g7a22f5b867ae1a13638739a242ccd588" title="First char in the &quot;high surrogate&quot; range.">CS_UC_CHAR_HIGH_SURROGATE_FIRST</a>)); <a name="l00419"></a>00419 <a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">OUTPUT_CHAR</a>((<a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>)((ch_shifted & 0x3ff) <a name="l00420"></a>00420 | <a class="code" href="group__util.html#g37ddcd2eb58d721be6531cc04691eafc" title="First char in the &quot;low surrogate&quot; range.">CS_UC_CHAR_LOW_SURROGATE_FIRST</a>)); <a name="l00421"></a>00421 } <a name="l00422"></a>00422 <span class="keywordflow">else</span> <a name="l00423"></a>00423 <span class="keywordflow">return</span> 0; <a name="l00424"></a>00424 <a name="l00425"></a>00425 <span class="keywordflow">return</span> encodedLen; <a name="l00426"></a>00426 } <a name="l00427"></a>00427 <a name="l00443"></a><a class="code" href="classcsUnicodeTransform.html#58c5c58bbf789057e6ea0b9bc86356a1">00443</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> EncodeUTF32 (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> ch, <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* buf, <a name="l00444"></a>00444 <span class="keywordtype">size_t</span> bufsize, <span class="keywordtype">bool</span> allowNonchars = <span class="keyword">false</span>) <a name="l00445"></a>00445 { <a name="l00446"></a>00446 <span class="keywordflow">if</span> ((!allowNonchars && ((<a class="code" href="group__util.html#gaa6e26882081c80c2723dec47e5afdb3" title="Test whether a code point is a Unicode noncharacter.">CS_UC_IS_NONCHARACTER</a>(ch)) <a name="l00447"></a>00447 || (<a class="code" href="group__util.html#g506d88b895df510ebcffba6d5acab4ac" title="Check whether a code is in the &quot;high&quot; or &quot;low surrogate&quot; range...">CS_UC_IS_SURROGATE</a>(ch)))) || (ch > <a class="code" href="group__util.html#g5e76da15993612b523f18deee6e40186" title="Highest valid Unicode codepoint.">CS_UC_LAST_CHAR</a>)) <a name="l00448"></a>00448 <span class="keywordflow">return</span> 0; <a name="l00449"></a>00449 <span class="keywordtype">size_t</span> bufRemaining = bufsize; <a name="l00450"></a>00450 <span class="keywordtype">int</span> encodedLen = 0; <a name="l00451"></a>00451 <a name="l00452"></a>00452 <a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">OUTPUT_CHAR</a>(ch); <a name="l00453"></a>00453 <a name="l00454"></a>00454 <span class="keywordflow">return</span> encodedLen; <a name="l00455"></a>00455 } <a name="l00456"></a>00456 <a name="l00461"></a><a class="code" href="classcsUnicodeTransform.html#0af2e3329f354f8626f43c5dc56c2634">00461</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> Encode (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> ch, <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>* buf, <a name="l00462"></a>00462 <span class="keywordtype">size_t</span> bufsize, <span class="keywordtype">bool</span> allowNonchars = <span class="keyword">false</span>) <a name="l00463"></a>00463 { <a name="l00464"></a>00464 <span class="keywordflow">return</span> EncodeUTF8 (ch, buf, bufsize, allowNonchars); <a name="l00465"></a>00465 } <a name="l00470"></a><a class="code" href="classcsUnicodeTransform.html#a61d511bc48e690af379cf27fe95836a">00470</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> Encode (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> ch, <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>* buf, <a name="l00471"></a>00471 <span class="keywordtype">size_t</span> bufsize, <span class="keywordtype">bool</span> allowNonchars = <span class="keyword">false</span>) <a name="l00472"></a>00472 { <a name="l00473"></a>00473 <span class="keywordflow">return</span> EncodeUTF16 (ch, buf, bufsize, allowNonchars); <a name="l00474"></a>00474 } <a name="l00479"></a><a class="code" href="classcsUnicodeTransform.html#0b5536e3d2a6d70d16e4d6c289011013">00479</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> Encode (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> ch, <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* buf, <a name="l00480"></a>00480 <span class="keywordtype">size_t</span> bufsize, <span class="keywordtype">bool</span> allowNonchars = <span class="keyword">false</span>) <a name="l00481"></a>00481 { <a name="l00482"></a>00482 <span class="keywordflow">return</span> EncodeUTF32 (ch, buf, bufsize, allowNonchars); <a name="l00483"></a>00483 } <a name="l00485"></a>00485 <span class="preprocessor">#undef OUTPUT_CHAR</span> <a name="l00486"></a>00486 <span class="preprocessor"></span> <a name="l00489"></a><a class="code" href="csuctransform_8h.html#1e2e100eca6f9d2e5335e1e31303f65e">00489</a> <span class="preprocessor">#define OUTPUT_CHAR(chr) _OUTPUT_CHAR(dest, chr)</span> <a name="l00490"></a>00490 <span class="preprocessor"></span> <a name="l00491"></a><a class="code" href="csuctransform_8h.html#5986e43141e3b48f52e8b4777445ecdc">00491</a> <span class="preprocessor">#define UCTF_CONVERTER(funcName, fromType, decoder, toType, encoder) \</span> <a name="l00492"></a>00492 <span class="preprocessor"> inline static size_t funcName (toType* dest, size_t destSize, \</span> <a name="l00493"></a>00493 <span class="preprocessor"> const fromType* source, size_t srcSize = (size_t)-1) \</span> <a name="l00494"></a>00494 <span class="preprocessor"> { \</span> <a name="l00495"></a>00495 <span class="preprocessor"> if ((srcSize == 0) || (source == 0)) \</span> <a name="l00496"></a>00496 <span class="preprocessor"> return 0; \</span> <a name="l00497"></a>00497 <span class="preprocessor"> \</span> <a name="l00498"></a>00498 <span class="preprocessor"> size_t bufRemaining = (destSize > 0) ? destSize - 1 : 0; \</span> <a name="l00499"></a>00499 <span class="preprocessor"> size_t encodedLen = 0; \</span> <a name="l00500"></a>00500 <span class="preprocessor"> \</span> <a name="l00501"></a>00501 <span class="preprocessor"> size_t srcChars = srcSize; \</span> <a name="l00502"></a>00502 <span class="preprocessor"> \</span> <a name="l00503"></a>00503 <span class="preprocessor"> if (srcSize == (size_t)-1) \</span> <a name="l00504"></a>00504 <span class="preprocessor"> { \</span> <a name="l00505"></a>00505 <span class="preprocessor"> srcChars = 0; \</span> <a name="l00506"></a>00506 <span class="preprocessor"> const fromType* sptr = source; \</span> <a name="l00507"></a>00507 <span class="preprocessor"> while (*sptr++ != 0) srcChars++; \</span> <a name="l00508"></a>00508 <span class="preprocessor"> } \</span> <a name="l00509"></a>00509 <span class="preprocessor"> \</span> <a name="l00510"></a>00510 <span class="preprocessor"> while (srcChars > 0) \</span> <a name="l00511"></a>00511 <span class="preprocessor"> { \</span> <a name="l00512"></a>00512 <span class="preprocessor"> utf32_char ch; \</span> <a name="l00513"></a>00513 <span class="preprocessor"> int scnt = decoder (source, srcChars, ch, 0); \</span> <a name="l00514"></a>00514 <span class="preprocessor"> if (scnt == 0) break; \</span> <a name="l00515"></a>00515 <span class="preprocessor"> int dcnt = encoder (ch, dest, bufRemaining); \</span> <a name="l00516"></a>00516 <span class="preprocessor"> if (dcnt == 0) \</span> <a name="l00517"></a>00517 <span class="preprocessor"> { \</span> <a name="l00518"></a>00518 <span class="preprocessor"> dcnt = encoder (CS_UC_CHAR_REPLACER, dest, bufRemaining); \</span> <a name="l00519"></a>00519 <span class="preprocessor"> } \</span> <a name="l00520"></a>00520 <span class="preprocessor"> \</span> <a name="l00521"></a>00521 <span class="preprocessor"> if ((size_t)dcnt >= bufRemaining) \</span> <a name="l00522"></a>00522 <span class="preprocessor"> { \</span> <a name="l00523"></a>00523 <span class="preprocessor"> if (dest && (destSize > 0)) dest += bufRemaining; \</span> <a name="l00524"></a>00524 <span class="preprocessor"> bufRemaining = 0; \</span> <a name="l00525"></a>00525 <span class="preprocessor"> } \</span> <a name="l00526"></a>00526 <span class="preprocessor"> else \</span> <a name="l00527"></a>00527 <span class="preprocessor"> { \</span> <a name="l00528"></a>00528 <span class="preprocessor"> bufRemaining -= dcnt; \</span> <a name="l00529"></a>00529 <span class="preprocessor"> if (dest && (destSize > 0)) dest += dcnt; \</span> <a name="l00530"></a>00530 <span class="preprocessor"> } \</span> <a name="l00531"></a>00531 <span class="preprocessor"> encodedLen += dcnt; \</span> <a name="l00532"></a>00532 <span class="preprocessor"> if ((size_t)scnt >= srcChars) break; \</span> <a name="l00533"></a>00533 <span class="preprocessor"> srcChars -= scnt; \</span> <a name="l00534"></a>00534 <span class="preprocessor"> source += scnt; \</span> <a name="l00535"></a>00535 <span class="preprocessor"> } \</span> <a name="l00536"></a>00536 <span class="preprocessor"> \</span> <a name="l00537"></a>00537 <span class="preprocessor"> if (dest) *dest = 0; \</span> <a name="l00538"></a>00538 <span class="preprocessor"> \</span> <a name="l00539"></a>00539 <span class="preprocessor"> return encodedLen + 1; \</span> <a name="l00540"></a>00540 <span class="preprocessor"> }</span> <a name="l00541"></a>00541 <span class="preprocessor"></span> <a name="l00557"></a><a class="code" href="classcsUnicodeTransform.html#bdad710dfb609d2d5edf6752506b4d52">00557</a> <a class="code" href="csuctransform_8h.html#5986e43141e3b48f52e8b4777445ecdc">UCTF_CONVERTER</a> (UTF8to16, <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>, UTF8Decode, <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>, EncodeUTF16); <a name="l00562"></a><a class="code" href="classcsUnicodeTransform.html#aab15b28adce906d66120d65717c47b7">00562</a> <a class="code" href="csuctransform_8h.html#5986e43141e3b48f52e8b4777445ecdc">UCTF_CONVERTER</a> (UTF8to32, <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>, UTF8Decode, <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>, EncodeUTF32); <a name="l00563"></a>00563 <a name="l00568"></a><a class="code" href="classcsUnicodeTransform.html#8ac51054b36028a0a20d031573cd1718">00568</a> <a class="code" href="csuctransform_8h.html#5986e43141e3b48f52e8b4777445ecdc">UCTF_CONVERTER</a> (UTF16to8, <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>, UTF16Decode, <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>, EncodeUTF8); <a name="l00573"></a><a class="code" href="classcsUnicodeTransform.html#464855759c78622ee2e361b10f000b6b">00573</a> <a class="code" href="csuctransform_8h.html#5986e43141e3b48f52e8b4777445ecdc">UCTF_CONVERTER</a> (UTF16to32, <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>, UTF16Decode, <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>, EncodeUTF32); <a name="l00574"></a>00574 <a name="l00579"></a><a class="code" href="classcsUnicodeTransform.html#9b93436f29d42d97060a477898d280de">00579</a> <a class="code" href="csuctransform_8h.html#5986e43141e3b48f52e8b4777445ecdc">UCTF_CONVERTER</a> (UTF32to8, <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>, UTF32Decode, <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>, EncodeUTF8); <a name="l00584"></a><a class="code" href="classcsUnicodeTransform.html#88fc5662ce654ab827edd968c119175d">00584</a> <a class="code" href="csuctransform_8h.html#5986e43141e3b48f52e8b4777445ecdc">UCTF_CONVERTER</a> (UTF32to16, <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>, UTF32Decode, <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>, EncodeUTF16); <a name="l00587"></a>00587 <span class="preprocessor">#undef UCTF_CONVERTER</span> <a name="l00588"></a>00588 <span class="preprocessor"></span><span class="preprocessor">#undef OUTPUT_CHAR</span> <a name="l00589"></a>00589 <span class="preprocessor"></span><span class="preprocessor">#undef _OUTPUT_CHAR</span> <a name="l00590"></a>00590 <span class="preprocessor"></span> <a name="l00591"></a>00591 <span class="preprocessor">#if (CS_WCHAR_T_SIZE == 1)</span> <a name="l00592"></a>00592 <span class="preprocessor"></span> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> UTF8toWC (<span class="keywordtype">wchar_t</span>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00593"></a>00593 <span class="keyword">const</span> <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00594"></a>00594 { <a name="l00595"></a>00595 <span class="keywordtype">size_t</span> srcChars = srcSize; <a name="l00596"></a>00596 <span class="keywordflow">if</span> (srcSize == (<span class="keywordtype">size_t</span>)-1) <a name="l00597"></a>00597 { <a name="l00598"></a>00598 srcChars = 0; <a name="l00599"></a>00599 <span class="keyword">const</span> <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>* sptr = source; <a name="l00600"></a>00600 <span class="keywordflow">while</span> (*sptr++ != 0) srcChars++; <a name="l00601"></a>00601 } <a name="l00602"></a>00602 <span class="keywordflow">if</span> ((dest != 0) && (destSize != 0)) <a name="l00603"></a>00603 { <a name="l00604"></a>00604 <span class="keywordtype">size_t</span> len = MIN (destSize - 1, srcChars); <a name="l00605"></a>00605 memcpy (dest, source, size * <span class="keyword">sizeof</span> (<span class="keywordtype">wchar_t</span>)); <a name="l00606"></a>00606 *(dest + len) = 0; <a name="l00607"></a>00607 } <a name="l00608"></a>00608 <span class="keywordflow">return</span> srcChars + 1; <a name="l00609"></a>00609 }; <a name="l00610"></a>00610 <a name="l00611"></a>00611 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> UTF16toWC (<span class="keywordtype">wchar_t</span>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00612"></a>00612 <span class="keyword">const</span> <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00613"></a>00613 { <a name="l00614"></a>00614 <span class="keywordflow">return</span> UTF16to8 ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>*)dest, destSize, source, srcSize); <a name="l00615"></a>00615 }; <a name="l00616"></a>00616 <a name="l00617"></a>00617 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> UTF32toWC (<span class="keywordtype">wchar_t</span>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00618"></a>00618 <span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00619"></a>00619 { <a name="l00620"></a>00620 <span class="keywordflow">return</span> UTF32to8 ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>*)dest, destSize, source, srcSize); <a name="l00621"></a>00621 }; <a name="l00622"></a>00622 <a name="l00623"></a>00623 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> WCtoUTF8 (<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00624"></a>00624 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00625"></a>00625 { <a name="l00626"></a>00626 <span class="keywordtype">size_t</span> srcChars = srcSize; <a name="l00627"></a>00627 <span class="keywordflow">if</span> (srcSize == (<span class="keywordtype">size_t</span>)-1) <a name="l00628"></a>00628 { <a name="l00629"></a>00629 srcChars = 0; <a name="l00630"></a>00630 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* sptr = source; <a name="l00631"></a>00631 <span class="keywordflow">while</span> (*sptr++ != 0) srcChars++; <a name="l00632"></a>00632 } <a name="l00633"></a>00633 <span class="keywordflow">if</span> ((dest != 0) && (destSize != 0)) <a name="l00634"></a>00634 { <a name="l00635"></a>00635 <span class="keywordtype">size_t</span> len = MIN (destSize - 1, srcChars); <a name="l00636"></a>00636 memcpy (dest, source, len * <span class="keyword">sizeof</span> (<span class="keywordtype">wchar_t</span>)); <a name="l00637"></a>00637 *(dest + len) = 0; <a name="l00638"></a>00638 } <a name="l00639"></a>00639 <span class="keywordflow">return</span> srcChars + 1; <a name="l00640"></a>00640 }; <a name="l00641"></a>00641 <a name="l00642"></a>00642 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> WCtoUTF16 (<a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00643"></a>00643 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00644"></a>00644 { <a name="l00645"></a>00645 <span class="keywordflow">return</span> UTF8to16 (dest, destSize, source, srcSize); <a name="l00646"></a>00646 }; <a name="l00647"></a>00647 <a name="l00648"></a>00648 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> WCtoUTF32 (<a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00649"></a>00649 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00650"></a>00650 { <a name="l00651"></a>00651 <span class="keywordflow">return</span> UTF8to32 (dest, destSize, source, srcSize); <a name="l00652"></a>00652 }; <a name="l00653"></a>00653 <a name="l00654"></a>00654 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> Decode (<span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* str, <span class="keywordtype">size_t</span> strlen, <a name="l00655"></a>00655 <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>& ch, <span class="keywordtype">bool</span>* isValid = 0, <span class="keywordtype">bool</span> returnNonChar = <span class="keyword">false</span>) <a name="l00656"></a>00656 { <a name="l00657"></a>00657 <span class="keywordflow">return</span> UTF8Decode ((<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>*)str, strlen, ch, isValid, returnNonChar); <a name="l00658"></a>00658 } <a name="l00659"></a>00659 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> Encode (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> ch, <span class="keywordtype">wchar_t</span>* buf, <a name="l00660"></a>00660 <span class="keywordtype">size_t</span> bufsize, <span class="keywordtype">bool</span> allowNonchars = <span class="keyword">false</span>) <a name="l00661"></a>00661 { <a name="l00662"></a>00662 <span class="keywordflow">return</span> EncodeUTF8 (ch, (<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>*)buf, bufsize, allowNonchars); <a name="l00663"></a>00663 } <a name="l00664"></a>00664 <span class="preprocessor">#elif (CS_WCHAR_T_SIZE == 2)</span> <a name="l00665"></a>00665 <span class="preprocessor"></span> <span class="comment">// Methods below for doxygen documentation are here as the size '2' is </span> <a name="l00666"></a>00666 <span class="comment">// default.</span> <a name="l00667"></a>00667 <a name="l00674"></a>00674 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> UTF8toWC (<span class="keywordtype">wchar_t</span>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00675"></a>00675 <span class="keyword">const</span> <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00676"></a>00676 { <a name="l00677"></a>00677 <span class="keywordflow">return</span> UTF8to16 ((<a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>*)dest, destSize, source, srcSize); <a name="l00678"></a>00678 }; <a name="l00679"></a>00679 <a name="l00684"></a>00684 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> UTF16toWC (<span class="keywordtype">wchar_t</span>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00685"></a>00685 <span class="keyword">const</span> <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00686"></a>00686 { <a name="l00687"></a>00687 <span class="keywordtype">size_t</span> srcChars = srcSize; <a name="l00688"></a>00688 <span class="keywordflow">if</span> (srcSize == (<span class="keywordtype">size_t</span>)-1) <a name="l00689"></a>00689 { <a name="l00690"></a>00690 srcChars = 0; <a name="l00691"></a>00691 <span class="keyword">const</span> <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>* sptr = source; <a name="l00692"></a>00692 <span class="keywordflow">while</span> (*sptr++ != 0) srcChars++; <a name="l00693"></a>00693 } <a name="l00694"></a>00694 <span class="keywordflow">if</span> ((dest != 0) && (destSize != 0)) <a name="l00695"></a>00695 { <a name="l00696"></a>00696 <span class="keywordtype">size_t</span> len = MIN (destSize - 1, srcChars); <a name="l00697"></a>00697 memcpy (dest, source, len * <span class="keyword">sizeof</span> (<span class="keywordtype">wchar_t</span>)); <a name="l00698"></a>00698 *(dest + len) = 0; <a name="l00699"></a>00699 } <a name="l00700"></a>00700 <span class="keywordflow">return</span> srcChars + 1; <a name="l00701"></a>00701 }; <a name="l00702"></a>00702 <a name="l00707"></a>00707 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> UTF32toWC (<span class="keywordtype">wchar_t</span>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00708"></a>00708 <span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00709"></a>00709 { <a name="l00710"></a>00710 <span class="keywordflow">return</span> UTF32to16 ((<a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>*)dest, destSize, source, srcSize); <a name="l00711"></a>00711 }; <a name="l00712"></a>00712 <a name="l00717"></a>00717 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> WCtoUTF8 (<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00718"></a>00718 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00719"></a>00719 { <a name="l00720"></a>00720 <span class="keywordflow">return</span> UTF16to8 (dest, destSize, (<a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>*)source, srcSize); <a name="l00721"></a>00721 }; <a name="l00722"></a>00722 <a name="l00727"></a>00727 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> WCtoUTF16 (<a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00728"></a>00728 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00729"></a>00729 { <a name="l00730"></a>00730 <span class="keywordtype">size_t</span> srcChars = srcSize; <a name="l00731"></a>00731 <span class="keywordflow">if</span> (srcSize == (<span class="keywordtype">size_t</span>)-1) <a name="l00732"></a>00732 { <a name="l00733"></a>00733 srcChars = 0; <a name="l00734"></a>00734 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* sptr = source; <a name="l00735"></a>00735 <span class="keywordflow">while</span> (*sptr++ != 0) srcChars++; <a name="l00736"></a>00736 } <a name="l00737"></a>00737 <span class="keywordflow">if</span> ((dest != 0) && (destSize != 0)) <a name="l00738"></a>00738 { <a name="l00739"></a>00739 <span class="keywordtype">size_t</span> len = MIN (destSize - 1, srcChars); <a name="l00740"></a>00740 memcpy (dest, source, len * <span class="keyword">sizeof</span> (<span class="keywordtype">wchar_t</span>)); <a name="l00741"></a>00741 *(dest + len) = 0; <a name="l00742"></a>00742 } <a name="l00743"></a>00743 <span class="keywordflow">return</span> srcChars + 1; <a name="l00744"></a>00744 }; <a name="l00745"></a>00745 <a name="l00750"></a>00750 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> WCtoUTF32 (<a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00751"></a>00751 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00752"></a>00752 { <a name="l00753"></a>00753 <span class="keywordflow">return</span> UTF16to32 (dest, destSize, (<a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>*)source, srcSize); <a name="l00754"></a>00754 }; <a name="l00755"></a>00755 <a name="l00756"></a>00756 <span class="comment">/* Decode()/Encode() overloads for wchar_t.</span> <a name="l00757"></a>00757 <span class="comment"> * - On VC7+, wchar_t may be an unsigned short or the special type __wchar_t.</span> <a name="l00758"></a>00758 <span class="comment"> * - On VC6 wchar_t is always an unsigned short. __wchar_t does not exist.</span> <a name="l00759"></a>00759 <span class="comment"> * Now there may be conflicts with the utf16_char overloads if wchar_t is</span> <a name="l00760"></a>00760 <span class="comment"> * an unsigned short. On the other hand, we would like to support VC7+'s</span> <a name="l00761"></a>00761 <span class="comment"> * built-in wchar_t as well.</span> <a name="l00762"></a>00762 <span class="comment"> * So: on VC7+, provide overloads for __wchar_t, on VC6, don't compile this</span> <a name="l00763"></a>00763 <span class="comment"> * code at all, on other compilers, provide overloads for wchar_t instead</span> <a name="l00764"></a>00764 <span class="comment"> * (by re#definining __wchar_t). </span> <a name="l00765"></a>00765 <span class="comment"> */</span> <a name="l00766"></a>00766 <span class="preprocessor">#if !defined(CS_COMPILER_MSVC) || (_MSC_VER > 1300)</span> <a name="l00767"></a>00767 <span class="preprocessor"></span><span class="preprocessor">#if !defined(CS_COMPILER_MSVC)</span> <a name="l00768"></a>00768 <span class="preprocessor"></span><span class="preprocessor"> #define __wchar_t wchar_t</span> <a name="l00769"></a>00769 <span class="preprocessor"></span><span class="preprocessor">#endif </span> <a name="l00770"></a>00770 <span class="preprocessor"></span> <a name="l00774"></a>00774 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> Decode (<span class="keyword">const</span> __wchar_t* str, <span class="keywordtype">size_t</span> strlen, <a name="l00775"></a>00775 <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>& ch, <span class="keywordtype">bool</span>* isValid = 0, <span class="keywordtype">bool</span> returnNonChar = <span class="keyword">false</span>) <a name="l00776"></a>00776 { <a name="l00777"></a>00777 <span class="keywordflow">return</span> UTF16Decode ((<a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>*)str, strlen, ch, isValid, returnNonChar); <a name="l00778"></a>00778 } <a name="l00783"></a>00783 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> Encode (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> ch, __wchar_t* buf, <a name="l00784"></a>00784 <span class="keywordtype">size_t</span> bufsize, <span class="keywordtype">bool</span> allowNonchars = <span class="keyword">false</span>) <a name="l00785"></a>00785 { <a name="l00786"></a>00786 <span class="keywordflow">return</span> EncodeUTF16 (ch, (<a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>*)buf, bufsize, allowNonchars); <a name="l00787"></a>00787 } <a name="l00788"></a>00788 <span class="preprocessor">#ifdef __wchar_t</span> <a name="l00789"></a>00789 <span class="preprocessor"></span><span class="preprocessor"> #undef __wchar_t</span> <a name="l00790"></a>00790 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00791"></a>00791 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00792"></a>00792 <span class="preprocessor"></span> <a name="l00793"></a>00793 <span class="preprocessor">#elif (CS_WCHAR_T_SIZE == 4)</span> <a name="l00794"></a>00794 <span class="preprocessor"></span> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> UTF8toWC (<span class="keywordtype">wchar_t</span>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00795"></a>00795 <span class="keyword">const</span> <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00796"></a>00796 { <a name="l00797"></a>00797 <span class="keywordflow">return</span> UTF8to32 ((<a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>*)dest, destSize, source, srcSize); <a name="l00798"></a>00798 }; <a name="l00799"></a>00799 <a name="l00800"></a>00800 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> UTF16toWC (<span class="keywordtype">wchar_t</span>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00801"></a>00801 <span class="keyword">const</span> <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00802"></a>00802 { <a name="l00803"></a>00803 <span class="keywordflow">return</span> UTF16to32 ((<a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>*)dest, destSize, source, srcSize); <a name="l00804"></a>00804 }; <a name="l00805"></a>00805 <a name="l00806"></a>00806 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> UTF32toWC (<span class="keywordtype">wchar_t</span>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00807"></a>00807 <span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00808"></a>00808 { <a name="l00809"></a>00809 <span class="keywordtype">size_t</span> srcChars = srcSize; <a name="l00810"></a>00810 <span class="keywordflow">if</span> (srcSize == (<span class="keywordtype">size_t</span>)-1) <a name="l00811"></a>00811 { <a name="l00812"></a>00812 srcChars = 0; <a name="l00813"></a>00813 <span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* sptr = source; <a name="l00814"></a>00814 <span class="keywordflow">while</span> (*sptr++ != 0) srcChars++; <a name="l00815"></a>00815 } <a name="l00816"></a>00816 <span class="keywordflow">if</span> ((dest != 0) && (destSize != 0)) <a name="l00817"></a>00817 { <a name="l00818"></a>00818 <span class="keywordtype">size_t</span> len = MIN (destSize - 1, srcChars); <a name="l00819"></a>00819 memcpy (dest, source, len * <span class="keyword">sizeof</span> (<span class="keywordtype">wchar_t</span>)); <a name="l00820"></a>00820 *(dest + len) = 0; <a name="l00821"></a>00821 } <a name="l00822"></a>00822 <span class="keywordflow">return</span> srcChars + 1; <a name="l00823"></a>00823 }; <a name="l00824"></a>00824 <a name="l00825"></a>00825 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> WCtoUTF8 (<a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00826"></a>00826 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00827"></a>00827 { <a name="l00828"></a>00828 <span class="keywordflow">return</span> UTF32to8 (dest, destSize, (<a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>*)source, srcSize); <a name="l00829"></a>00829 }; <a name="l00830"></a>00830 <a name="l00831"></a>00831 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> WCtoUTF16 (<a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00832"></a>00832 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00833"></a>00833 { <a name="l00834"></a>00834 <span class="keywordflow">return</span> UTF32to16 (dest, destSize, (<a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>*)source, srcSize); <a name="l00835"></a>00835 }; <a name="l00836"></a>00836 <a name="l00837"></a>00837 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">size_t</span> WCtoUTF32 (<a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* dest, <span class="keywordtype">size_t</span> destSize, <a name="l00838"></a>00838 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* source, <span class="keywordtype">size_t</span> srcSize) <a name="l00839"></a>00839 { <a name="l00840"></a>00840 <span class="keywordtype">size_t</span> srcChars = srcSize; <a name="l00841"></a>00841 <span class="keywordflow">if</span> (srcSize == (<span class="keywordtype">size_t</span>)-1) <a name="l00842"></a>00842 { <a name="l00843"></a>00843 srcChars = 0; <a name="l00844"></a>00844 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* sptr = source; <a name="l00845"></a>00845 <span class="keywordflow">while</span> (*sptr++ != 0) srcChars++; <a name="l00846"></a>00846 } <a name="l00847"></a>00847 <span class="keywordflow">if</span> ((dest != 0) && (destSize != 0)) <a name="l00848"></a>00848 { <a name="l00849"></a>00849 <span class="keywordtype">size_t</span> len = MIN (destSize - 1, srcChars); <a name="l00850"></a>00850 memcpy (dest, source, len * <span class="keyword">sizeof</span> (<span class="keywordtype">wchar_t</span>)); <a name="l00851"></a>00851 *(dest + len) = 0; <a name="l00852"></a>00852 } <a name="l00853"></a>00853 <span class="keywordflow">return</span> srcChars + 1; <a name="l00854"></a>00854 }; <a name="l00855"></a>00855 <a name="l00856"></a>00856 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> Decode (<span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* str, <span class="keywordtype">size_t</span> strlen, <a name="l00857"></a>00857 <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>& ch, <span class="keywordtype">bool</span>* isValid = 0, <span class="keywordtype">bool</span> returnNonChar = <span class="keyword">false</span>) <a name="l00858"></a>00858 { <a name="l00859"></a>00859 <span class="keywordflow">return</span> UTF32Decode ((<a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>*)str, strlen, ch, isValid, returnNonChar); <a name="l00860"></a>00860 } <a name="l00861"></a>00861 <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> Encode (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> ch, <span class="keywordtype">wchar_t</span>* buf, <a name="l00862"></a>00862 <span class="keywordtype">size_t</span> bufsize, <span class="keywordtype">bool</span> allowNonchars = <span class="keyword">false</span>) <a name="l00863"></a>00863 { <a name="l00864"></a>00864 <span class="keywordflow">return</span> EncodeUTF32 (ch, (<a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>*)buf, bufsize, allowNonchars); <a name="l00865"></a>00865 } <a name="l00866"></a>00866 <span class="preprocessor">#else</span> <a name="l00867"></a>00867 <span class="preprocessor"></span><span class="preprocessor"> #error Odd-sized, unsupported wchar_t!</span> <a name="l00868"></a>00868 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00869"></a>00869 <span class="preprocessor"></span> <a name="l00882"></a><a class="code" href="classcsUnicodeTransform.html#0d4b2524b9ec9c6f3fe3e61e6ab97e00">00882</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> UTF8Skip (<span class="keyword">const</span> <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>* str, <span class="keywordtype">size_t</span> maxSkip) <a name="l00883"></a>00883 { <a name="l00884"></a>00884 <span class="keywordflow">if</span> (maxSkip < 1) <span class="keywordflow">return</span> 0; <a name="l00885"></a>00885 <a name="l00886"></a>00886 <span class="keywordflow">if</span> ((*str & 0x80) == 0) <a name="l00887"></a>00887 { <a name="l00888"></a>00888 <span class="keywordflow">return</span> 1; <a name="l00889"></a>00889 } <a name="l00890"></a>00890 <span class="keywordflow">else</span> <a name="l00891"></a>00891 { <a name="l00892"></a>00892 <span class="keywordtype">int</span> n = 0; <a name="l00893"></a>00893 <span class="keywordflow">while</span> ((n < 7) && ((*str & (1 << (7 - n))) != 0)) { n++; } <a name="l00894"></a>00894 <a name="l00895"></a>00895 <span class="keywordflow">if</span> ((n < 2) || (n > 6)) <a name="l00896"></a>00896 { <a name="l00897"></a>00897 <span class="keywordflow">return</span> 1; <a name="l00898"></a>00898 } <a name="l00899"></a>00899 <a name="l00900"></a>00900 <span class="keywordtype">int</span> skip = 1; <a name="l00901"></a>00901 <a name="l00902"></a>00902 <span class="keywordflow">for</span> (; skip < n; skip++) <a name="l00903"></a>00903 { <a name="l00904"></a>00904 <span class="keywordflow">if</span> (((str[skip] & 0xc0) != 0x80) || ((<span class="keywordtype">size_t</span>)skip > maxSkip)) <a name="l00905"></a>00905 { <a name="l00906"></a>00906 <span class="keywordflow">break</span>; <a name="l00907"></a>00907 } <a name="l00908"></a>00908 } <a name="l00909"></a>00909 <span class="keywordflow">return</span> skip; <a name="l00910"></a>00910 } <a name="l00911"></a>00911 } <a name="l00912"></a>00912 <a name="l00923"></a><a class="code" href="classcsUnicodeTransform.html#ddfc476b7f8edcb769e2d778610225e9">00923</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> UTF8Rewind (<span class="keyword">const</span> <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>* str, <span class="keywordtype">size_t</span> maxRew) <a name="l00924"></a>00924 { <a name="l00925"></a>00925 <span class="keywordflow">if</span> (maxRew < 1) <span class="keywordflow">return</span> 0; <a name="l00926"></a>00926 <a name="l00927"></a>00927 <span class="keyword">const</span> <a class="code" href="group__util.html#g60f3213e4468d7d223f3a27ad792ad38" title="A single char in a UTF8 encoded string.">utf8_char</a>* pos = str - 1; <a name="l00928"></a>00928 <a name="l00929"></a>00929 <span class="keywordflow">if</span> ((*pos & 0x80) == 0) <a name="l00930"></a>00930 { <a name="l00931"></a>00931 <span class="keywordflow">return</span> 1; <a name="l00932"></a>00932 } <a name="l00933"></a>00933 <a name="l00934"></a>00934 <span class="comment">// Skip backward to the first byte of the sequence.</span> <a name="l00935"></a>00935 <span class="keywordtype">int</span> skip = 1; <a name="l00936"></a>00936 <span class="keywordflow">while</span> (((*pos & 0xc0) == 0x80) && ((<span class="keywordtype">size_t</span>)skip < maxRew)) <a name="l00937"></a>00937 { <a name="l00938"></a>00938 skip++; <a name="l00939"></a>00939 pos--; <a name="l00940"></a>00940 } <a name="l00941"></a>00941 <a name="l00942"></a>00942 <span class="keywordflow">return</span> skip; <a name="l00943"></a>00943 } <a name="l00944"></a>00944 <a name="l00950"></a><a class="code" href="classcsUnicodeTransform.html#d4c06533155e5a6825bda80f65bbac45">00950</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> UTF16Skip (<span class="keyword">const</span> <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>* str, <span class="keywordtype">size_t</span> maxSkip) <a name="l00951"></a>00951 { <a name="l00952"></a>00952 <span class="keywordflow">if</span> (<a class="code" href="group__util.html#gc8cdcb503070d89ec9b289a26925743e" title="Check whether a code is in the &quot;high surrogate&quot; range.">CS_UC_IS_HIGH_SURROGATE</a> (*str)) <a name="l00953"></a>00953 <span class="keywordflow">return</span> (<span class="keywordtype">int</span>)(MIN(maxSkip, (<span class="keywordtype">size_t</span>)2)); <a name="l00954"></a>00954 <span class="keywordflow">else</span> <a name="l00955"></a>00955 <span class="keywordflow">return</span> (<span class="keywordtype">int</span>)(MIN(maxSkip, (<span class="keywordtype">size_t</span>)1)); <a name="l00956"></a>00956 } <a name="l00957"></a>00957 <a name="l00963"></a><a class="code" href="classcsUnicodeTransform.html#d90b496800a6591cf1c98b43184ebc51">00963</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> UTF16Rewind (<span class="keyword">const</span> <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>* str, <span class="keywordtype">size_t</span> maxRew) <a name="l00964"></a>00964 { <a name="l00965"></a>00965 <span class="keywordflow">if</span> (maxRew < 1) <span class="keywordflow">return</span> 0; <a name="l00966"></a>00966 <a name="l00967"></a>00967 <span class="keyword">const</span> <a class="code" href="group__util.html#g02506e0f0963f4590ed154373a24f43f" title="A single char in a UTF16 encoded string.">utf16_char</a>* pos = str - 1; <a name="l00968"></a>00968 <span class="keywordflow">if</span> (!<a class="code" href="group__util.html#g506d88b895df510ebcffba6d5acab4ac" title="Check whether a code is in the &quot;high&quot; or &quot;low surrogate&quot; range...">CS_UC_IS_SURROGATE</a>(*pos)) <a name="l00969"></a>00969 <span class="keywordflow">return</span> 1; <a name="l00970"></a>00970 <span class="keywordflow">else</span> <a name="l00971"></a>00971 { <a name="l00972"></a>00972 <span class="keywordflow">if</span> ((maxRew > 1) && (<a class="code" href="group__util.html#gc8cdcb503070d89ec9b289a26925743e" title="Check whether a code is in the &quot;high surrogate&quot; range.">CS_UC_IS_HIGH_SURROGATE</a>(*(pos - 1)))) <a name="l00973"></a>00973 <span class="keywordflow">return</span> 2; <a name="l00974"></a>00974 <span class="keywordflow">else</span> <a name="l00975"></a>00975 <span class="keywordflow">return</span> 1; <a name="l00976"></a>00976 } <a name="l00977"></a>00977 } <a name="l00978"></a>00978 <a name="l00984"></a><a class="code" href="classcsUnicodeTransform.html#637e29374e0a8419ced315e08af920b8">00984</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> UTF32Skip (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* str, <span class="keywordtype">size_t</span> maxSkip) <a name="l00985"></a>00985 { <a name="l00986"></a>00986 (void)str; <span class="comment">// silence gcc</span> <a name="l00987"></a>00987 <span class="keywordflow">return</span> (<span class="keywordtype">int</span>)(MIN(maxSkip, (<span class="keywordtype">size_t</span>)1)); <a name="l00988"></a>00988 } <a name="l00989"></a>00989 <a name="l00995"></a><a class="code" href="classcsUnicodeTransform.html#310ed95864f7d579e378077f40ab4df3">00995</a> <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">int</span> UTF32Rewind (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* str, <span class="keywordtype">size_t</span> maxRew) <a name="l00996"></a>00996 { <a name="l00997"></a>00997 (void)str; <span class="comment">// silence gcc</span> <a name="l00998"></a>00998 <span class="keywordflow">if</span> (maxRew < 1) <span class="keywordflow">return</span> 0; <a name="l00999"></a>00999 <span class="keywordflow">return</span> 1; <a name="l01000"></a>01000 } <a name="l01015"></a>01015 <span class="keyword">static</span> <span class="keywordtype">size_t</span> MapToUpper (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> ch, <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* dest, <a name="l01016"></a>01016 <span class="keywordtype">size_t</span> destSize, <a class="code" href="group__util.html#g91ad9478d81a7aaf2593e8d9c3d06a14" title="Shortcut for default unsigned int.">uint</a> flags = 0); <a name="l01021"></a>01021 <span class="keyword">static</span> <span class="keywordtype">size_t</span> MapToLower (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> ch, <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* dest, <a name="l01022"></a>01022 <span class="keywordtype">size_t</span> destSize, <a class="code" href="group__util.html#g91ad9478d81a7aaf2593e8d9c3d06a14" title="Shortcut for default unsigned int.">uint</a> flags = 0); <a name="l01028"></a>01028 <span class="keyword">static</span> <span class="keywordtype">size_t</span> MapToFold (<span class="keyword">const</span> <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> ch, <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a>* dest, <a name="l01029"></a>01029 <span class="keywordtype">size_t</span> destSize, <a class="code" href="group__util.html#g91ad9478d81a7aaf2593e8d9c3d06a14" title="Shortcut for default unsigned int.">uint</a> flags = 0); <a name="l01031"></a>01031 }; <a name="l01032"></a>01032 <a name="l01035"></a>01035 <span class="preprocessor">#endif</span> <a name="l01036"></a>01036 <span class="preprocessor"></span> </pre></div><hr size="1"><address><small>Generated for Crystal Space 1.2.1 by <a href="http://www.doxygen.org/index.html">doxygen</a> 1.5.3 </small></address> </div></body> </html>