get_next_char


Description:

public bool get_next_char (ref int index, out unichar c)

Finds the next UTF-8 character in the string after index.

index does not have to be at the beginning of a UTF-8 character. No check is made to see if the character found is actually valid other than it starts with an appropriate byte.

Example: Utf8-handling, get_next_char:

public static int main (string[] args) {
string wisdom = "口は禍の元。";
unichar c = 0;
int index = 0;

// Output:
// ``0: 3: 口``
// ``1: 6: は``
// ``2: 9: 禍``
// ``3: 12: の``
// ``4: 15: 元``
// ``5: 18: 。``

for (int cnt = 0; wisdom.get_next_char (ref index, out c); cnt++) {
print ("%d: %d:\t%s\n", cnt, index, c.to_string ());
}

return 0;
}

valac --pkg glib-2.0 string.get_next_char.vala

Parameters:

index

a byte offset to a unicode character encoded as UTF-8

c

the location to store the next unichar

Returns:

true if a character is found in the string, false otherwise.