View source code
Display the source code in std/uni.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Function std.uni.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 code point mappings unlike sicmp. The cost of icmp being pedantically correct is slightly worse performance.

int icmp(S1, S2) (
  S1 r1,
  S2 r2
)
if (isForwardRange!S1 && isSomeChar!(ElementEncodingType!S1) && isForwardRange!S2 && isSomeChar!(ElementEncodingType!S2));

Parameters

NameDescription
r1 a forward range of characters
r2 a forward range of characters

Returns

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

See Also

sicmp cmp

Example

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

Example

By using 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;

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

Authors

Dmitry Olshansky

License

Boost License 1.0.