Variant.bytestring


Description:

[ Version ( since = "2.26" ) ]
public Variant.bytestring (string value)

Creates an array-of-bytes Variant with the contents of string.

This function is just like Variant.string except that the string need not be valid UTF-8.

The nul terminator character at the end of the string is stored in the array.

Example: Create a new byte string Variant:

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

// Output: ``'Hello, world!', 13``
print ("'%s', %"+size_t.FORMAT+"\n", var1.dup_bytestring (out length), length);
// Output: ``'Hello, world!'``
print ("'%s'\n", var1.get_bytestring ());

return 0;
}

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

Parameters:

string

a normal nul-terminated string in no particular encoding

Returns:

a floating reference to a new bytestring Variant instance