⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glib-character-set-conversion.html

📁 glid编写实例
💻 HTML
📖 第 1 页 / 共 5 页
字号:
a native implementation.</p><p>GLib provides <a href="glib-Character-Set-Conversion.html#g-convert"><code class="function">g_convert()</code></a> and <a href="glib-Character-Set-Conversion.html#g-locale-to-utf8"><code class="function">g_locale_to_utf8()</code></a> which are likelymore convenient than the raw iconv wrappers.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>to_codeset</code></em>&#160;:</span></td><td> destination codeset</td></tr><tr><td><span class="term"><em class="parameter"><code>from_codeset</code></em>&#160;:</span></td><td> source codeset</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td> a "conversion descriptor", or (GIConv)-1 if opening the converter failed.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2962695"></a><h3><a name="g-iconv"></a>g_iconv ()</h3><a class="indexterm" name="id2962706"></a><pre class="programlisting">size_t      g_iconv                         (<a href="glib-Character-Set-Conversion.html#GIConv">GIConv</a> converter,                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **inbuf,                                             <a href="glib-Basic-Types.html#gsize">gsize</a> *inbytes_left,                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **outbuf,                                             <a href="glib-Basic-Types.html#gsize">gsize</a> *outbytes_left);</pre><p>Same as the standard UNIX routine <code class="function">iconv()</code>, butmay be implemented via libiconv on UNIX flavors that lacka native implementation.</p><p>GLib provides <a href="glib-Character-Set-Conversion.html#g-convert"><code class="function">g_convert()</code></a> and <a href="glib-Character-Set-Conversion.html#g-locale-to-utf8"><code class="function">g_locale_to_utf8()</code></a> which are likelymore convenient than the raw iconv wrappers.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>converter</code></em>&#160;:</span></td><td> conversion descriptor from <a href="glib-Character-Set-Conversion.html#g-iconv-open"><code class="function">g_iconv_open()</code></a></td></tr><tr><td><span class="term"><em class="parameter"><code>inbuf</code></em>&#160;:</span></td><td> bytes to convert</td></tr><tr><td><span class="term"><em class="parameter"><code>inbytes_left</code></em>&#160;:</span></td><td> inout parameter, bytes remaining to convert in <em class="parameter"><code>inbuf</code></em></td></tr><tr><td><span class="term"><em class="parameter"><code>outbuf</code></em>&#160;:</span></td><td> converted output bytes</td></tr><tr><td><span class="term"><em class="parameter"><code>outbytes_left</code></em>&#160;:</span></td><td> inout parameter, bytes available to fill in <em class="parameter"><code>outbuf</code></em></td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td> count of non-reversible conversions, or -1 on error</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2962914"></a><h3><a name="g-iconv-close"></a>g_iconv_close ()</h3><a class="indexterm" name="id2962925"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gint">gint</a>        g_iconv_close                   (<a href="glib-Character-Set-Conversion.html#GIConv">GIConv</a> converter);</pre><p>Same as the standard UNIX routine <code class="function">iconv_close()</code>, butmay be implemented via libiconv on UNIX flavors that lacka native implementation. Should be called to clean upthe conversion descriptor from <a href="glib-Character-Set-Conversion.html#g-iconv-open"><code class="function">g_iconv_open()</code></a> whenyou are done converting things.</p><p>GLib provides <a href="glib-Character-Set-Conversion.html#g-convert"><code class="function">g_convert()</code></a> and <a href="glib-Character-Set-Conversion.html#g-locale-to-utf8"><code class="function">g_locale_to_utf8()</code></a> which are likelymore convenient than the raw iconv wrappers.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>converter</code></em>&#160;:</span></td><td> a conversion descriptor from <a href="glib-Character-Set-Conversion.html#g-iconv-open"><code class="function">g_iconv_open()</code></a></td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td> -1 on error, 0 on success</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2963047"></a><h3><a name="g-locale-to-utf8"></a>g_locale_to_utf8 ()</h3><a class="indexterm" name="id2963058"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>*      g_locale_to_utf8                (const <a href="glib-Basic-Types.html#gchar">gchar</a> *opsysstring,                                             <a href="glib-Basic-Types.html#gssize">gssize</a> len,                                             <a href="glib-Basic-Types.html#gsize">gsize</a> *bytes_read,                                             <a href="glib-Basic-Types.html#gsize">gsize</a> *bytes_written,                                             <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Converts a string which is in the encoding used for strings bythe C runtime (usually the same as that used by the operatingsystem) in the current locale into a UTF-8 string.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>opsysstring</code></em>&#160;:</span></td><td>   a string in the encoding of the current locale. On Windows                this means the system codepage.</td></tr><tr><td><span class="term"><em class="parameter"><code>len</code></em>&#160;:</span></td><td>           the length of the string, or -1 if the string is                nul-terminated<sup>[<a href="#ftn.nul-unsafe">1</a>]</sup>. </td></tr><tr><td><span class="term"><em class="parameter"><code>bytes_read</code></em>&#160;:</span></td><td>    location to store the number of bytes in the                input string that were successfully converted, or <code class="literal">NULL</code>.                Even if the conversion was successful, this may be                 less than <em class="parameter"><code>len</code></em> if there were partial characters                at the end of the input. If the error                <span class="type">G_CONVERT_ERROR_ILLEGAL_SEQUENCE</span> occurs, the value                stored will the byte offset after the last valid                input sequence.</td></tr><tr><td><span class="term"><em class="parameter"><code>bytes_written</code></em>&#160;:</span></td><td> the number of bytes stored in the output buffer (not                 including the terminating nul).</td></tr><tr><td><span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></td><td>         location to store the error occuring, or <code class="literal">NULL</code> to ignore                errors. Any of the errors in <a href="glib-Character-Set-Conversion.html#GConvertError"><span class="type">GConvertError</span></a> may occur.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td> The converted string, or <code class="literal">NULL</code> on an error.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2963268"></a><h3><a name="g-filename-to-utf8"></a>g_filename_to_utf8 ()</h3><a class="indexterm" name="id2963279"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>*      g_filename_to_utf8              (const <a href="glib-Basic-Types.html#gchar">gchar</a> *opsysstring,                                             <a href="glib-Basic-Types.html#gssize">gssize</a> len,                                             <a href="glib-Basic-Types.html#gsize">gsize</a> *bytes_read,                                             <a href="glib-Basic-Types.html#gsize">gsize</a> *bytes_written,                                             <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Converts a string which is in the encoding used by GLib for filenamesinto a UTF-8 string.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>opsysstring</code></em>&#160;:</span></td><td>   a string in the encoding for filenames</td></tr><tr><td><span class="term"><em class="parameter"><code>len</code></em>&#160;:</span></td><td>           the length of the string, or -1 if the string is                nul-terminated<sup>[<a href="#ftn.nul-unsafe">1</a>]</sup>. </td></tr><tr><td><span class="term"><em class="parameter"><code>bytes_read</code></em>&#160;:</span></td><td>    location to store the number of bytes in the                input string that were successfully converted, or <code class="literal">NULL</code>.                Even if the conversion was successful, this may be                 less than <em class="parameter"><code>len</code></em> if there were partial characters                at the end of the input. If the error                <span class="type">G_CONVERT_ERROR_ILLEGAL_SEQUENCE</span> occurs, the value                stored will the byte offset after the last valid                input sequence.</td></tr><tr><td><span class="term"><em class="parameter"><code>bytes_written</code></em>&#160;:</span></td><td> the number of bytes stored in the output buffer (not                 including the terminating nul).</td></tr><tr><td><span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></td><td>         location to store the error occuring, or <code class="literal">NULL</code> to ignore                errors. Any of the errors in <a href="glib-Character-Set-Conversion.html#GConvertError"><span class="type">GConvertError</span></a> may occur.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td> The converted string, or <code class="literal">NULL</code> on an error.</td></tr>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -