append_len


Description:

public unowned StringBuilder append_len (string val, ssize_t len)

Appends len bytes of val to this.

If len is positive, val may contain embedded nuls and need not be nul-terminated. It is the caller's responsibility to ensure that val has at least len addressable bytes.

If len is negative, val must be nul-terminated and len is considered to request the entire string length. This makes append_len equivalent to append .

Example: Append n bytes of a string:

public static int main (string[] args) {
// Output: ``hello, world!``
StringBuilder subbuilder = new StringBuilder ("hello");
StringBuilder builder = new StringBuilder ();
builder.append_len (subbuilder.str, subbuilder.len);
builder.append_len (", world!\n", 9);
print (builder.str);
return 0;
}

valac --pkg glib-2.0 GLib.StringBuilder.append_len.vala

Parameters:

this

a StringBuilder

val

bytes to append

len

number of bytes of val to use, or -1 for all of val

Returns:

this