last_index_of_char


Description:

public int last_index_of_char (unichar c, int start_index = 0)

Find the rightmost occurrence of the given Unicode character in a UTF-8 encoded string.

Example: Find the rightmost occurrence of the given char:

public static int main (string[] args) {
string filename = "blueprint-dalek.vs1.pdf";

// Output: ``19``
int index = filename.last_index_of_char ('.');
print ("%d\n", index);

// Output: ``-1``
index = filename.last_index_of_char ('Ω');
print ("%d\n", index);
return 0;
}

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

Parameters:

c

a unicode character

start_index

the starting position for the search in bytes.

Returns:

the byte index of the last occurrence of the character, or -1 if the character does not occur.