Method

GLibVariantget_string

since: 2.24

Declaration [src]

const gchar*
g_variant_get_string (
  GVariant* value,
  gsize* length
)

Description [src]

Returns the string value of a GVariant instance with a string type. This includes the types G_VARIANT_TYPE_STRING, G_VARIANT_TYPE_OBJECT_PATH and G_VARIANT_TYPE_SIGNATURE.

The string will always be UTF-8 encoded, will never be NULL, and will never contain nul bytes.

If length is non-NULL then the length of the string (in bytes) is returned there. For trusted values, this information is already known. Untrusted values will be validated and, if valid, a strlen() will be performed. If invalid, a default value will be returned — for G_VARIANT_TYPE_OBJECT_PATH, this is "/", and for other types it is the empty string.

It is an error to call this function with a value of any type other than those three.

The return value remains valid as long as value exists.

Available since: 2.24

Parameters

length

Type: gsize*

A pointer to a #gsize, to store the length.

The argument will be set by the function.
The argument can be NULL.

Return value

Type: const gchar*

The constant string, UTF-8 encoded.

The returned data is owned by the instance.
The value is a NUL terminated UTF-8 string.