Variant.string


Description:

public Variant.string (string value)

Creates a string Variant with the contents of string.

string must be valid UTF-8, and must not be null. To encode potentially- null strings, use Variant with `ms` as the format string.

Example: Create a new string Variant:

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


// Output: ``'Hello, world!'``
print ("'%s'\n", (string) var1);
// Output: ``'Hello, world!', 13``
print ("'%s', %"+size_t.FORMAT+"\n", var1.get_string (out length), length);
// Output: ``'Hello, world!', 13``
print ("'%s', %"+size_t.FORMAT+"\n", var1.dup_string (out length), length);
return 0;
}

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

Parameters:

string

a normal UTF-8 nul-terminated string

Returns:

a floating reference to a new string Variant instance