This is the opposite of string.get_next_char().
There is a difference though, to be more convenient in a loop:
get_next_char() returns the current chararcter, and the next index.
get_prev_char() returns the previous character, and the previous index.
Fixes bug 655185.
[CCode (cname = "g_utf8_prev_char")]
public unowned string prev_char ();
+ [CCode (cname = "g_utf8_prev_char")]
+ static char* utf8_prev_char (char* str);
+ public bool get_prev_char (ref int index, out unichar c) {
+ if (0 < index) {
+ index = (int) (utf8_prev_char ((char*) this + index) - (char*) this);
+ c = utf8_get_char ((char*) this + index);
+ return true;
+ } else {
+ c = 0;
+ return false;
+ }
+ }
+
[Deprecated (replacement = "string.length")]
[CCode (cname = "strlen")]
public long len ();