glib-character-set-conversion.html
来自「最新gtk中文资料集」· HTML 代码 · 共 1,101 行 · 第 1/5 页
HTML
1,101 行
<a name="id2992340"></a><h3><a name="g-filename-to-uri"></a>g_filename_to_uri ()</h3><a class="indexterm" name="id2992354"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>* g_filename_to_uri (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename, const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *hostname, <a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Converts an absolute filename to an escaped ASCII-encoded URI, with the pathcomponent following Section 3.3. of RFC 2396.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td><td> an absolute filename specified in the GLib file name encoding, which is the on-disk file name bytes on Unix, and UTF-8 on Windows</td></tr><tr><td><p><span class="term"><em class="parameter"><code>hostname</code></em> :</span></p></td><td> A UTF-8 encoded hostname, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> for none.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td><td> location to store the error occuring, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore errors. Any of the errors in <a class="link" href="glib-Character-Set-Conversion.html#GConvertError"><span class="type">GConvertError</span></a> may occur.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> a newly-allocated string holding the resulting URI, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on an error.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2992504"></a><h3><a name="g-get-filename-charsets"></a>g_get_filename_charsets ()</h3><a class="indexterm" name="id2992519"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> g_get_filename_charsets (G_CONST_RETURN <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> ***charsets);</pre><p>Determines the preferred character sets used for filenames.The first character set from the <em class="parameter"><code>charsets</code></em> is the filename encoding, thesubsequent character sets are used when trying to generate a displayablerepresentation of a filename, see <a class="link" href="glib-Character-Set-Conversion.html#g-filename-display-name"><code class="function">g_filename_display_name()</code></a>.</p><p>On Unix, the character sets are determined by consulting theenvironment variables <code class="envar">G_FILENAME_ENCODING</code> and<code class="envar">G_BROKEN_FILENAMES</code>. On Windows, the character setused in the GLib API is always UTF-8 and said environment variableshave no effect.</p><p><code class="envar">G_FILENAME_ENCODING</code> may be set to a comma-separated list of character set names. The special token "@locale" is taken to mean the character set for the <a class="link" href="glib-running.html#setlocale" title="Locale">current locale</a>. If <code class="envar">G_FILENAME_ENCODING</code> is not set, but <code class="envar">G_BROKEN_FILENAMES</code> is, the character set of the current locale is taken as the filename encoding. If neither environment variable is set, UTF-8 is taken as the filename encoding, but the characterset of the current locale is also put in the list of encodings.</p><p>The returned <em class="parameter"><code>charsets</code></em> belong to GLib and must not be freed.</p><p>Note that on Unix, regardless of the locale character set or<code class="envar">G_FILENAME_ENCODING</code> value, the actual file names present on a system might be in any random encoding or just gibberish.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>charsets</code></em> :</span></p></td><td> return location for the <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>-terminated list of encoding names</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the filename encoding is UTF-8.</td></tr></tbody></table></div><p class="since">Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id2992692"></a><h3><a name="g-filename-display-name"></a>g_filename_display_name ()</h3><a class="indexterm" name="id2992708"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>* g_filename_display_name (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename);</pre><p>Converts a filename into a valid UTF-8 string. The conversion is not necessarily reversible, so you should keep the original around and use the return value of this function only for display purposes.Unlike <a class="link" href="glib-Character-Set-Conversion.html#g-filename-to-utf8"><code class="function">g_filename_to_utf8()</code></a>, the result is guaranteed to be non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> even if the filename actually isn't in the GLib file name encoding.</p><p>If GLib can not make sense of the encoding of <em class="parameter"><code>filename</code></em>, as a last resort it replaces unknown characters with U+FFFD, the Unicode replacement character.You can search the result for the UTF-8 encoding of this character (which is"\357\277\275" in octal notation) to find out if <em class="parameter"><code>filename</code></em> was in an invalidencoding.</p><p>If you know the whole pathname of the file you should use<a class="link" href="glib-Character-Set-Conversion.html#g-filename-display-basename"><code class="function">g_filename_display_basename()</code></a>, since that allows location-basedtranslation of filenames.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td><td> a pathname hopefully in the GLib file name encoding</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> a newly allocated string containing a rendition of the filename in valid UTF-8</td></tr></tbody></table></div><p class="since">Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id2992840"></a><h3><a name="g-filename-display-basename"></a>g_filename_display_basename ()</h3><a class="indexterm" name="id2992856"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>* g_filename_display_basename (const <a class="link" 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>If GLib can not make sense of the encoding of <em class="parameter"><code>filename</code></em>, as a last resort it replaces unknown characters with U+FFFD, the Unicode replacement character.You can search the result for the UTF-8 encoding of this character (which is"\357\277\275" in octal notation) to find out if <em class="parameter"><code>filename</code></em> was in an invalidencoding.</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 class="link" 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><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td><td> an absolute pathname in the GLib file name encoding</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></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 class="since">Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id2992970"></a><h3><a name="g-uri-list-extract-uris"></a>g_uri_list_extract_uris ()</h3><a class="indexterm" name="id2992985"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>** g_uri_list_extract_uris (const <a class="link" 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><p><span class="term"><em class="parameter"><code>uri_list</code></em> :</span></p></td><td> an URI list </td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> a newly allocated <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>-terminated list of strings holding the individual URIs. The array should be freed with <a class="link" href="glib-String-Utility-Fun
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?