strncasecmp

A case-insensitive string comparison, corresponding to the standard strncasecmp() function on platforms which support it. It is similar to funcGLib.strcasecmp except it only compares the first n characters of the strings.

More...
int
strncasecmp
(
string s1
,
string s2
,
uint n
)

Parameters

s1 string

string to compare with s2

s2 string

string to compare with s1

n uint

the maximum number of characters to compare

Return Value

Type: int

0 if the strings match, a negative value if s1 < s2, or a positive value if s1 > s2

Detailed Description

Deprecated: The problem with [glib.global.strncasecmp] is that it does the comparison by calling toupper()/tolower(). These functions are locale-specific and operate on single bytes. However, it is impossible to handle things correctly from an internationalization standpoint by operating on bytes, since characters may be multibyte. Thus [glib.global.strncasecmp] is broken if your string is guaranteed to be ASCII, since it is locale-sensitive, and it's broken if your string is localized, since it doesn't work on many encodings at all, including UTF-8, EUC-JP, etc.

There are therefore two replacement techniques: funcGLib.ascii_strncasecmp, which only works on ASCII and is not locale-sensitive, and funcGLib.utf8_casefold followed by strcmp() on the resulting strings, which is good for case-insensitive sorting of UTF-8.