[vala] glib-2.0: Add string.valid_char



commit f84f37c39b9b35fd2a2c18e32832b3f4c989c4da
Author: Jürg Billeter <j bitron ch>
Date:   Sat Jan 15 18:46:08 2011 +0100

    glib-2.0: Add string.valid_char

 vapi/glib-2.0.vapi |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index 6c726f7..c3abf8b 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -992,6 +992,17 @@ public class string {
 		return ((char*) this)[index];
 	}
 
+	// checks whether valid string character starts at specified index
+	// embedded NULs are not supported by the string class
+	public bool valid_char (int index) {
+		uint8 c = ((uint8*) this)[index];
+		if (c == 0x00 || (c >= 0x80 && c < 0xc2) || c >= 0xf5) {
+			return false;
+		} else {
+			return true;
+		}
+	}
+
 	[CCode (cname = "g_utf8_next_char")]
 	public unowned string next_char ();
 	[CCode (cname = "g_utf8_get_char")]



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]