]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
glib-2.0: Add string.valid_char
authorJürg Billeter <j@bitron.ch>
Sat, 15 Jan 2011 17:46:08 +0000 (18:46 +0100)
committerJürg Billeter <j@bitron.ch>
Sat, 15 Jan 2011 17:46:08 +0000 (18:46 +0100)
vapi/glib-2.0.vapi

index 6c726f7dbb56d4ce19a23a1c9bd3eb0aae8a4030..c3abf8b38b81ca109e176ae679dfca7e7076295f 100644 (file)
@@ -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")]