icmp

Does case insensitive comparison of r1 and r2. Follows the rules of full case-folding mapping. This includes matching as equal german ß with "ss" and other 1:M $(CODEPOINT) mappings unlike sicmp. The cost of icmp being pedantically correct is slightly worse performance.

version(!std_uni_bootstrap)
int
icmp
(
S1
S2
)
(
S1 r1
,
S2 r2
)

Parameters

r1 S1

a forward range of characters

r2 S2

a forward range of characters

Return Value

Type: int

An int that is 0 if the strings match, <0 if str1 is lexicographically "less" than str2, >0 if str1 is lexicographically "greater" than str2

Examples

assert(icmp("Rußland", "Russland") == 0);
assert(icmp("ᾩ -> \u1F70\u03B9", "\u1F61\u03B9 -> ᾲ") == 0);

By using std.utf.byUTF and its aliases, GC allocations via auto-decoding and thrown exceptions can be avoided, making icmp @safe @nogc nothrow pure.

import std.utf : byDchar;

assert(icmp("Rußland".byDchar, "Russland".byDchar) == 0);
assert(icmp("ᾩ -> \u1F70\u03B9".byDchar, "\u1F61\u03B9 -> ᾲ".byDchar) == 0);

See Also

Meta