the_Foundation [release-1.0]

String: Added a method to check UTF-8 validity

=> 7ff1adf809c047a349243e6e142a08d52dd69716

diff --git a/include/the_Foundation/string.h b/include/the_Foundation/string.h
index 742d82d..6d16dd4 100644
--- a/include/the_Foundation/string.h
+++ b/include/the_Foundation/string.h
@@ -280,6 +280,7 @@ iLocalDef iRangecc range_CStr(const char *cstr) {
 const char *    cstr_Rangecc        (iRangecc); /* returns NULL-terminated collected copy */
 const iString * string_Rangecc      (iRangecc); /* returns a collected String */
 
+iBool           isUtf8_Rangecc      (iRangecc); /* checks if the range is well-formed UTF-8 */
 size_t          length_Rangecc      (iRangecc); /* returns number of characters in the range */
 
 #define         cmp_Rangecc(d, cstr) cmpCStrSc_Rangecc((d), (cstr), &iCaseSensitive)
diff --git a/src/string.c b/src/string.c
index 3f786bc..33e9ee9 100644
--- a/src/string.c
+++ b/src/string.c
@@ -390,6 +390,10 @@ size_t length_String(const iString *d) {
     return u8_mbsnlen((const uint8_t *) cstr_String(d), size_String(d));
 }
 
+iBool isUtf8_Rangecc(iRangecc d) {
+    return u8_check((const uint8_t *) d.start, size_Range(&d)) == NULL;
+}
+
 size_t length_Rangecc(const iRangecc d) {
     /*
     size_t n = 0;
Proxy Information
Original URL
gemini://git.skyjake.fi/the_Foundation/release-1.0/cdiff/7ff1adf809c047a349243e6e142a08d52dd69716
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
23.187358 milliseconds
Gemini-to-HTML Time
0.170493 milliseconds

This content has been proxied by September (ba2dc).