View source code
Display the source code in std/uni.d from which this page was generated on
github.
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.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.uni.sicmp
Does basic case-insensitive comparison of strings
and str1
.
This function uses simpler comparison rule thus achieving better performance
than str2
icmp
. However keep in mind the warning below.
Prototype
int sicmp(S1, S2)( S1 str1, S2 str2 ) if (isForwardRange!S1 && is(Unqual!(ElementType!S1) == dchar) && isForwardRange!S2 && is(Unqual!(ElementType!S2) == dchar));
Parameters
Name | Description |
---|---|
str1 | a string or a ForwardRange of dchar s |
str2 | a string or a ForwardRange of dchar s |
Returns
An int
that is 0 if the strings match,
<0 if
is lexicographically "less" than str1
,
>0 if str2
is lexicographically "greater" than str1
str2
Warning
This function only handles 1:1 mapping and thus is not sufficient for certain alphabets like German, Greek and few others.
Example
assert(sicmp("Август", "авгусТ") == 0); // Greek also works as long as there is no 1:M mapping in sight assert(sicmp("ΌΎ", "όύ") == 0); // things like the following won't get matched as equal // Greek small letter iota with dialytika and tonos assert(sicmp("ΐ", "\u03B9\u0308\u0301") != 0); // while icmp has no problem with that assert(icmp("ΐ", "\u03B9\u0308\u0301") == 0); assert(icmp("ΌΎ", "όύ") == 0);
See Also
Authors
Dmitry Olshansky