📄 strings.sgml
字号:
<entry>the character to insert.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the <link linkend="GString">GString</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-string-insert-unichar">g_string_insert_unichar ()</title><programlisting><link linkend="GString">GString</link>* g_string_insert_unichar (<link linkend="GString">GString</link> *string, <link linkend="gssize">gssize</link> pos, <link linkend="gunichar">gunichar</link> wc);</programlisting><para>Converts a Unicode character into UTF-8, and insert itinto the string at the given position.</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>string</parameter> :</entry><entry> a <link linkend="Gstring">Gstring</link></entry></row><row><entry align="right"><parameter>pos</parameter> :</entry><entry> the position at which to insert character, or -1 to append at the end of the string.</entry></row><row><entry align="right"><parameter>wc</parameter> :</entry><entry> a Unicode character</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> <parameter>string</parameter></entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-string-insert-len">g_string_insert_len ()</title><programlisting><link linkend="GString">GString</link>* g_string_insert_len (<link linkend="GString">GString</link> *string, <link linkend="gssize">gssize</link> pos, const <link linkend="gchar">gchar</link> *val, <link linkend="gssize">gssize</link> len);</programlisting><para>Inserts <parameter>len</parameter> bytes of <parameter>val</parameter> into <parameter>string</parameter> at <parameter>pos</parameter>. Because <parameter>len</parameter> is provided, <parameter>val</parameter> may contain embedded nuls and need not be nul-terminated. If <parameter>pos</parameter> is -1, bytes are inserted at the end of the string.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>string</parameter> :</entry><entry>a <link linkend="GString">GString</link>.</entry></row><row><entry align="right"><parameter>pos</parameter> :</entry><entry>position in <parameter>string</parameter> where insertion should happen, or -1 for at the end.</entry></row><row><entry align="right"><parameter>val</parameter> :</entry><entry>bytes to insert.</entry></row><row><entry align="right"><parameter>len</parameter> :</entry><entry>number of bytes of <parameter>val</parameter> to insert.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the <link linkend="GString">GString</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-string-erase">g_string_erase ()</title><programlisting><link linkend="GString">GString</link>* g_string_erase (<link linkend="GString">GString</link> *string, <link linkend="gssize">gssize</link> pos, <link linkend="gssize">gssize</link> len);</programlisting><para>Removes <parameter>len</parameter> characters from a <link linkend="GString">GString</link>, starting at position <parameter>pos</parameter>.The rest of the <link linkend="GString">GString</link> is shifted down to fill the gap.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>string</parameter> :</entry><entry>a <link linkend="GString">GString</link>.</entry></row><row><entry align="right"><parameter>pos</parameter> :</entry><entry>the position of the characters to remove.</entry></row><row><entry align="right"><parameter>len</parameter> :</entry><entry>the number of characters to remove, or -1 to remove all following characters.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the <link linkend="GString">GString</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-string-truncate">g_string_truncate ()</title><programlisting><link linkend="GString">GString</link>* g_string_truncate (<link linkend="GString">GString</link> *string, <link linkend="gsize">gsize</link> len);</programlisting><para>Cuts off the end of the GString, leaving the first <parameter>len</parameter> characters.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>string</parameter> :</entry><entry>a <link linkend="GString">GString</link>.</entry></row><row><entry align="right"><parameter>len</parameter> :</entry><entry>the new size of the <link linkend="GString">GString</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the <link linkend="GString">GString</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-string-set-size">g_string_set_size ()</title><programlisting><link linkend="GString">GString</link>* g_string_set_size (<link linkend="GString">GString</link> *string, <link linkend="gsize">gsize</link> len);</programlisting><para>Sets the length of a <link linkend="GString">GString</link>. If the length is less thanthe current length, the string will be truncated. If thelength is greater than the current length, the contentsof the newly added area are undefined. (However, asalways, string->str[string->len] will be a nul byte.)</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>string</parameter> :</entry><entry> a <link linkend="GString">GString</link></entry></row><row><entry align="right"><parameter>len</parameter> :</entry><entry> the new length</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> <parameter>string</parameter></entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-string-free">g_string_free ()</title><programlisting><link linkend="gchar">gchar</link>* g_string_free (<link linkend="GString">GString</link> *string, <link linkend="gboolean">gboolean</link> free_segment);</programlisting><para>Frees the memory allocated for the <link linkend="GString">GString</link>.If <parameter>free_segment</parameter> is <literal>TRUE</literal> it also frees the character data.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>string</parameter> :</entry><entry>a <link linkend="GString">GString</link>.</entry></row><row><entry align="right"><parameter>free_segment</parameter> :</entry><entry>if <literal>TRUE</literal> the actual character data is freed as well.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry></entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-string-up">g_string_up ()</title><programlisting><link linkend="GString">GString</link>* g_string_up (<link linkend="GString">GString</link> *string);</programlisting><warning><para><literal>g_string_up</literal> is deprecated and should not be used in newly-written code.</para></warning><para>Converts a <link linkend="GString">GString</link> to upper case.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>string</parameter> :</entry><entry>a <link linkend="GString">GString</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the <link linkend="GString">GString</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-string-down">g_string_down ()</title><programlisting><link linkend="GString">GString</link>* g_string_down (<link linkend="GString">GString</link> *string);</programlisting><warning><para><literal>g_string_down</literal> is deprecated and should not be used in newly-written code.</para></warning><para>Converts a <link linkend="GString">GString</link> to lower case.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>string</parameter> :</entry><entry>a <link linkend="GString">GString</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the <link linkend="GString">GString</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-string-hash">g_string_hash ()</title><programlisting><link linkend="guint">guint</link> g_string_hash (const <link linkend="GString">GString</link> *str);</programlisting><para>Creates a hash code for <parameter>str</parameter>; for use with <link linkend="GHashTable">GHashTable</link>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>str</parameter> :</entry><entry>a string to hash.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>hash code for <parameter>str</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-string-equal">g_string_equal ()</title><programlisting><link linkend="gboolean">gboolean</link> g_string_equal (const <link linkend="GString">GString</link> *v, const <link linkend="GString">GString</link> *v2);</programlisting><para>Compares two strings for equality, returning <literal>TRUE</literal> if they are equal. For use with <link linkend="GHashTable">GHashTable</link>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>v</parameter> :</entry><entry>a <link linkend="GString">GString</link>.</entry></row><row><entry align="right"><parameter>v2</parameter> :</entry><entry>another <link linkend="GString">GString</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry><literal>TRUE</literal> if they strings are the same length and contain the same bytes.</entry></row></tbody></tgroup></informaltable></refsect2></refsect1></refentry>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -