Adds a string onto the end of a GLib.String, expanding it if necessary.
the string to append onto the end of string
string
Adds a byte onto the end of a GLib.String, expanding it if necessary.
the byte to append onto the end of string
string
Appends len bytes of val to string.
If len is positive, val may contain embedded nuls and need
not be nul-terminated. It is the caller's responsibility to
ensure that val has at least len addressable bytes.
If len is negative, val must be nul-terminated and len
is considered to request the entire string length. This
makes g_string_append_len() equivalent to g_string_append().
bytes to append
number of bytes of val to use, or -1 for all of val
string
Appends unescaped to string, escaping any characters that
are reserved in URIs using URI-style escape sequences.
a string
a string of reserved characters allowed to be used, or null
set true if the escaped string may include UTF8 characters
string
Copies the bytes from a string into a GLib.String,
destroying any previous contents. It is rather like
the standard strcpy() function, except that you do not
have to worry about having enough space to copy the string.
the string to copy into string
string
Copies the GLib.String instance and its contents.
This will preserve the allocation length of the GLib.String in the copy.
a copy of string
Compares two strings for equality, returning true if they are equal.
For use with GLib.HashTable.
another GLib.String
true if the strings are the same length and contain the same bytes
Removes len bytes from a GLib.String, starting at position pos.
The rest of the GLib.String is shifted down to fill the gap.
the position of the content to remove
the number of bytes to remove, or -1 to remove all following bytes
string
Frees the memory allocated for the GLib.String.
If free_segment is true it also frees the character data. If
it's false, the caller gains ownership of the buffer and must
free it after use with g_free().
Instead of passing false to this function, consider using
g_string_free_and_steal().
if true, the actual character data is freed as well
the character data of string (i.e. null if free_segment is true)
Frees the memory allocated for the GLib.String.
The caller gains ownership of the buffer and
must free it after use with g_free().
the character data of string
Transfers ownership of the contents of string to a newly allocated
GLib.Bytes. The GLib.String structure itself is deallocated, and it is
therefore invalid to use string after invoking this function.
Note that while GLib.String ensures that its buffer always has a trailing nul character (not reflected in its "len"), the returned GLib.Bytes does not include this extra nul; i.e. it has length exactly equal to the "len" member.
A newly allocated GLib.Bytes containing contents of string; string itself is freed
Inserts a copy of a string into a GLib.String, expanding it if necessary.
the position to insert the copy of the string
the string to insert
string
Inserts a byte into a GLib.String, expanding it if necessary.
the position to insert the byte
the byte to insert
string
Inserts len bytes of val into string at pos.
If len is positive, val may contain embedded nuls and need
not be nul-terminated. It is the caller's responsibility to
ensure that val has at least len addressable bytes.
If len is negative, val must be nul-terminated and len
is considered to request the entire string length.
If pos is -1, bytes are inserted at the end of the string.
position in string where insertion should happen, or -1 for at the end
bytes to insert
number of bytes of val to insert, or -1 for all of val
string
Overwrites part of a string, lengthening it if necessary. This function will work with embedded nuls.
the position at which to start overwriting
the string that will overwrite the string starting at pos
the number of bytes to write from val
string
Adds a string on to the start of a GLib.String, expanding it if necessary.
the string to prepend on the start of string
string
Adds a byte onto the start of a GLib.String, expanding it if necessary.
the byte to prepend on the start of the GLib.String
string
Prepends len bytes of val to string.
If len is positive, val may contain embedded nuls and need
not be nul-terminated. It is the caller's responsibility to
ensure that val has at least len addressable bytes.
If len is negative, val must be nul-terminated and len
is considered to request the entire string length. This
makes g_string_prepend_len() equivalent to g_string_prepend().
bytes to prepend
number of bytes in val to prepend, or -1 for all of val
string
Replaces the string find with the string replace in a GLib.String up to
limit times. If the number of instances of find in the GLib.String is
less than limit, all instances are replaced. If limit is 0,
all instances of find are replaced.
If find is the empty string, since versions 2.69.1 and 2.68.4 the
replacement will be inserted no more than once per possible position
(beginning of string, end of string and between characters). This did
not work correctly in earlier versions.
If limit is zero and more than G_MAXUINT instances of find are in
the input string, they will all be replaced, but the return value will
be capped at G_MAXUINT.
the string to find in string
the string to insert in place of find
the maximum instances of find to replace with replace, or 0 for no limit
the number of find and replace operations performed, up to G_MAXUINT
Sets the length of a GLib.String. If the length is less than the current length, the string will be truncated. If the length is greater than the current length, the contents of the newly added area are undefined. (However, as always, string->str[string->len] will be a nul byte.)
the new length
string
StaticnewStaticnew_Staticnew_Staticsized_
A GLib.String is an object that handles the memory management of a C string.
The emphasis of GLib.String is on text, typically UTF-8. Crucially, the "str" member of a GLib.String is guaranteed to have a trailing nul character, and it is therefore always safe to call functions such as
strchr()orstrdup()on it.However, a GLib.String can also hold arbitrary binary data, because it has a "len" member, which includes any possible embedded nul characters in the data. Conceptually then, GLib.String is like a GLib.ByteArray with the addition of many convenience methods for text, and a guaranteed nul terminator.