summaryrefslogtreecommitdiffhomepage
path: root/src/utf8code.c
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2022-05-30 23:15:53 +0200
committerTyge Lovset <[email protected]>2022-05-30 23:15:53 +0200
commit2688277a4efe011ffd35f0e3ce859bb110207d8e (patch)
tree9157f10e8bb740da10f24b25c3485984bef25f72 /src/utf8code.c
parente29110e296b7b4618778d4e57646fc5fe0103bd6 (diff)
downloadSTC-modified-2688277a4efe011ffd35f0e3ce859bb110207d8e.tar.gz
STC-modified-2688277a4efe011ffd35f0e3ce859bb110207d8e.zip
Added utf8_icmp_n() case insensitive comparison.
Diffstat (limited to 'src/utf8code.c')
-rw-r--r--src/utf8code.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/utf8code.c b/src/utf8code.c
index c58f78b6..cef3efca 100644
--- a/src/utf8code.c
+++ b/src/utf8code.c
@@ -100,6 +100,19 @@ uint32_t utf8_toupper(uint32_t c) {
return c;
}
+int utf8_icmp_n(const char* s1, const char* s2, size_t u8max) {
+ int ret = 0;
+ utf8_decode_t d1 = {UTF8_OK}, d2 = {UTF8_OK};
+ for (; u8max--; s1 += d1.size, s2 += d2.size) {
+ utf8_peek(&d1, s1);
+ utf8_peek(&d2, s2);
+ ret = utf8_tolower(d1.codep) - utf8_tolower(d2.codep);
+ if (ret || !*s2)
+ break;
+ }
+ return ret;
+}
+
bool utf8_isupper(uint32_t c) {
return utf8_tolower(c) != c;
}