[utils] adding unicode_equals function in string_utils for testing equality of unicode char arrays

This commit is contained in:
Al
2017-11-11 02:45:41 -05:00
parent 3c6629ae3d
commit 665b780422
2 changed files with 14 additions and 0 deletions

View File

@@ -390,6 +390,19 @@ uint32_array *unicode_codepoints(const char *str) {
return a;
}
bool unicode_equals(uint32_array *u1_array, uint32_array *u2_array) {
size_t len1 = u1_array->n;
size_t len2 = u2_array->n;
if (len1 != len2) return false;
uint32_t *u1 = u1_array->a;
uint32_t *u2 = u2_array->a;
for (size_t i = 0; i < len1; i++) {
if (u1[i] != u2[i]) return false;
}
return true;
}
int utf8_compare_len(const char *str1, const char *str2, size_t len) {
if (len == 0) return 0;