}
}
-int utf8_check_full(const char *buffer, int size)
+int utf8_check_full(const char *buffer, int size, int32_t *codepoint)
{
int i;
int32_t value = 0;
return 0;
}
+ if(codepoint)
+ *codepoint = value;
+
return 1;
}
+const char *utf8_iterate(const char *buffer, int32_t *codepoint)
+{
+ int count;
+ int32_t value;
+
+ if(!*buffer)
+ return buffer;
+
+ count = utf8_check_first(buffer[0]);
+ if(count <= 0)
+ return NULL;
+
+ if(count == 1)
+ value = (unsigned char)buffer[0];
+ else
+ {
+ if(!utf8_check_full(buffer, count, &value))
+ return NULL;
+ }
+
+ if(codepoint)
+ *codepoint = value;
+
+ return buffer + count;
+}
+
int utf8_check_string(const char *string, int length)
{
int i;
if(i + count > length)
return 0;
- if(!utf8_check_full(&string[i], count))
+ if(!utf8_check_full(&string[i], count, NULL))
return 0;
i += count - 1;