summaryrefslogtreecommitdiffhomepage
path: root/include/stc/utf8.h
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 /include/stc/utf8.h
parente29110e296b7b4618778d4e57646fc5fe0103bd6 (diff)
downloadSTC-modified-2688277a4efe011ffd35f0e3ce859bb110207d8e.tar.gz
STC-modified-2688277a4efe011ffd35f0e3ce859bb110207d8e.zip
Added utf8_icmp_n() case insensitive comparison.
Diffstat (limited to 'include/stc/utf8.h')
-rw-r--r--include/stc/utf8.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/stc/utf8.h b/include/stc/utf8.h
index 67722345..333a0f92 100644
--- a/include/stc/utf8.h
+++ b/include/stc/utf8.h
@@ -35,8 +35,10 @@ bool utf8_isalpha(uint32_t c);
bool utf8_isalnum(uint32_t c);
uint32_t utf8_tolower(uint32_t c);
uint32_t utf8_toupper(uint32_t c);
+
bool utf8_valid(const char* s);
bool utf8_valid_n(const char* s, size_t n);
+int utf8_icmp_n(const char* s1, const char* s2, size_t u8max);
/* encode/decode next utf8 codepoint. */
enum { UTF8_OK = 0, UTF8_ERROR = 4 };
@@ -46,6 +48,10 @@ void utf8_peek(utf8_decode_t* d, const char *s);
unsigned utf8_encode(char *out, uint32_t c);
void utf8_decode(utf8_decode_t *d, const uint8_t b);
+/* case-insensitive utf8 string comparison */
+STC_INLINE int utf8_icmp(const char* s1, const char* s2)
+ { return utf8_icmp_n(s1, s2, (size_t)(-1)); }
+
/* number of characters in the utf8 codepoint from s */
STC_INLINE unsigned utf8_codep_size(const char *s) {
unsigned b = (uint8_t)*s;