📄 glib-character-set-conversion.html
字号:
<div class="refsect2" lang="en"><a name="id2964276"></a><h3><a name="g-filename-display-basename"></a>g_filename_display_basename ()</h3><a class="indexterm" name="id2964288"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>* g_filename_display_basename (const <a href="glib-Basic-Types.html#gchar">gchar</a> *filename);</pre><p>Returns the display basename for the particular filename, guaranteedto be valid UTF-8. The display name might not be identical to the filename,for instance there might be problems converting it to UTF-8, and some filescan be translated in the display</p><p>You must pass the whole absolute pathname to this functions so thattranslation of well known locations can be done.</p><p>This function is preferred over <a href="glib-Character-Set-Conversion.html#g-filename-display-name"><code class="function">g_filename_display_name()</code></a> if you know thewhole path, as it allows translation.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>filename</code></em> :</span></td><td> an absolute pathname in the GLib file name encoding</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> a newly allocated string containing a rendition of the basename of the filename in valid UTF-8</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id2964380"></a><h3><a name="g-uri-list-extract-uris"></a>g_uri_list_extract_uris ()</h3><a class="indexterm" name="id2964390"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>** g_uri_list_extract_uris (const <a href="glib-Basic-Types.html#gchar">gchar</a> *uri_list);</pre><p>Splits an URI list conforming to the text/uri-listmime type defined in RFC 2483 into individual URIs,discarding any comments. The URIs are not validated.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>uri_list</code></em> :</span></td><td> an URI list </td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> a newly allocated <code class="literal">NULL</code>-terminated list of strings holding the individual URIs. The array should be freed with <a href="glib-String-Utility-Functions.html#g-strfreev"><code class="function">g_strfreev()</code></a>.</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id2964475"></a><h3><a name="g-locale-from-utf8"></a>g_locale_from_utf8 ()</h3><a class="indexterm" name="id2964486"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>* g_locale_from_utf8 (const <a href="glib-Basic-Types.html#gchar">gchar</a> *utf8string, <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 from UTF-8 to the encoding used for strings bythe C runtime (usually the same as that used by the operatingsystem) in the current locale.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>utf8string</code></em> :</span></td><td> a UTF-8 encoded string </td></tr><tr><td><span class="term"><em class="parameter"><code>len</code></em> :</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> :</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> :</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> :</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> :</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="id2964694"></a><h3><a name="GConvertError"></a>enum GConvertError</h3><a class="indexterm" name="id2964704"></a><pre class="programlisting">typedef enum { G_CONVERT_ERROR_NO_CONVERSION, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, G_CONVERT_ERROR_FAILED, G_CONVERT_ERROR_PARTIAL_INPUT, G_CONVERT_ERROR_BAD_URI, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH} GConvertError;</pre><p>Error codes returned by character set conversion routines.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><code class="literal">G_CONVERT_ERROR_NO_CONVERSION</code></span></td><td>Conversion between the requested character setsis not supported.</td></tr><tr><td><span class="term"><code class="literal">G_CONVERT_ERROR_ILLEGAL_SEQUENCE</code></span></td><td>Invalid byte sequence in conversion input.</td></tr><tr><td><span class="term"><code class="literal">G_CONVERT_ERROR_FAILED</code></span></td><td>Conversion failed for some reason.</td></tr><tr><td><span class="term"><code class="literal">G_CONVERT_ERROR_PARTIAL_INPUT</code></span></td><td>Partial character sequence at end of input.</td></tr><tr><td><span class="term"><code class="literal">G_CONVERT_ERROR_BAD_URI</code></span></td><td>URI is invalid.</td></tr><tr><td><span class="term"><code class="literal">G_CONVERT_ERROR_NOT_ABSOLUTE_PATH</code></span></td><td>Pathname is not an absolute path.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2964820"></a><h3><a name="g-get-charset"></a>g_get_charset ()</h3><a class="indexterm" name="id2964831"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a> g_get_charset (G_CONST_RETURN char **charset);</pre><p>Obtains the character set for the current locale; you might usethis character set as an argument to <a href="glib-Character-Set-Conversion.html#g-convert"><code class="function">g_convert()</code></a>, to convert fromthe current locale's encoding to some other encoding. (Frequently<a href="glib-Character-Set-Conversion.html#g-locale-to-utf8"><code class="function">g_locale_to_utf8()</code></a> and <a href="glib-Character-Set-Conversion.html#g-locale-from-utf8"><code class="function">g_locale_from_utf8()</code></a> are nice shortcuts,though.)</p><p>The return value is <code class="literal">TRUE</code> if the locale's encoding is UTF-8, in thatcase you can perhaps avoid calling <a href="glib-Character-Set-Conversion.html#g-convert"><code class="function">g_convert()</code></a>.</p><p>The string returned in <em class="parameter"><code>charset</code></em> is not allocated, and should not befreed.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>charset</code></em> :</span></td><td> return location for character set name</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> <code class="literal">TRUE</code> if the returned charset is UTF-8</td></tr></tbody></table></div></div></div><div class="footnotes"><br><hr width="100" align="left"><div class="footnote"><p><sup>[<a name="ftn.nul-unsafe" href="#nul-unsafe">1</a>] </sup> Note that some encodings may allow nul bytes to occur inside strings. In that case, using -1 for the <em class="parameter"><code>len</code></em> parameter is unsafe. </p></div></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="glib-String-Utility-Functions.html"><b><< String Utility Functions</b></a></td><td align="right"><a accesskey="n" href="glib-Unicode-Manipulation.html"><b>Unicode Manipulation >></b></a></td></tr></table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -