String
A GString
is an object that handles the memory management of a C string.
The emphasis of GString
is on text, typically UTF-8. Crucially, the "str" member of a GString
is guaranteed to have a trailing nul character, and it is therefore always safe to call functions such as strchr()
or strdup()
on it.
However, a GString
can also hold arbitrary binary data, because it has a "len" member, which includes any possible embedded nul characters in the data. Conceptually then, GString
is like a GByteArray
with the addition of many convenience methods for text, and a guaranteed nul terminator.
Skipped during bindings generation
method
append_printf
: Varargs parameter is not supportedparameter
args
: va_listmethod
printf
: Varargs parameter is not supportedparameter
args
: va_list
Constructors
Properties
Functions
Converts a Unicode character into UTF-8, and appends it to the string.
Appends @unescaped to @string, escaping any characters that are reserved in URIs using URI-style escape sequences.
Frees the memory allocated for the #GString.
Transfers ownership of the contents of @string to a newly allocated #GBytes. The #GString structure itself is deallocated, and it is therefore invalid to use @string after invoking this function.
Converts a Unicode character into UTF-8, and insert it into the string at the given position.
Overwrites part of a string, lengthening it if necessary. This function will work with embedded nuls.
Prepends @len bytes of @val to @string.
Converts a Unicode character into UTF-8, and prepends it to the string.
Sets the length of a #GString. 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->strstring->len will be a nul byte.)