[ Version ( since = "2.26" ) ]
public unowned string get_bytestring ()

Returns the string value of a Variant instance with an array-of-bytes type.

The string has no particular encoding.

If the array does not end with a nul terminator character, the empty string is returned. For this reason, you can always trust that a non- null nul-terminated string will be returned by this function.

If the array contains a nul terminator character somewhere other than the last byte then the returned string is the string, up to the first such nul character.

g_variant_get_fixed_array should be used instead if the array contains arbitrary data that could not be nul-terminated or could contain nul bytes.

It is an error to call this function with a this that is not an array of bytes.

The return value remains valid as long as this exists.

Example: Get a byte string:

public static int main (string[] args) {
Variant var1 = new Variant.bytestring ("Hello, world!");

// Output: ``'Hello, world!'``
print ("'%s'\n", var1.get_bytestring ());

return 0;

valac --pkg glib-2.0 GLib.Variant.get_bytestring.vala



an array-of-bytes Variant instance


the constant string