Commit 2e62a3f0 authored by Chris Müller's avatar Chris Müller

lib: add a compare function for utf8 strings (byte compare)

parent 5dcad80f
......@@ -252,6 +252,24 @@ cry_utf8_str(const byte* str1, const byte* str2)
}
int
cry_utf8_compare(const byte* str1, const byte* str2)
{
register const byte* s1 = str1;
register const byte* s2 = str2;
register byte c1, c2;
do {
c1 = *s1++;
c2 = *s2++;
if(c1 == '\0')
return c1 - c2;
} while(c1 == c2);
return c1 - c2;
}
size_t
cry_utf8_len(const byte* str)
{
......
......@@ -21,6 +21,7 @@
#include "standard.h"
int cry_utf8_validate(const byte* str);
int cry_utf8_compare(const byte* str1, const byte* str2);
byte* cry_utf8_chr(const byte* str, unicode character);
byte* cry_utf8_rchr(const byte* str, unicode character);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment