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.sicmp
Does basic case-insensitive comparison of r1
and r2
.
This function uses simpler comparison rule thus achieving better performance
than icmp
. However keep in mind the warning below.
int sicmp(S1, S2)
(
scope S1 r1,
scope S2 r2
)
if (isInputRange!S1 && isSomeChar!(ElementEncodingType!S1) && isInputRange!S2 && isSomeChar!(ElementEncodingType!S2));
Parameters
Name | Description |
---|---|
r1 | an input range of characters |
r2 | an input range of characters |
Returns
An int
that is 0 if the strings match,
<0 if r1
is lexicographically "less" than r2
,
>0 if r1
is lexicographically "greater" than r2
Warning
This function only handles 1:1 code point mapping and thus is not sufficient for certain alphabets like German, Greek and few others.
See Also
Example
writeln(sicmp("Август", "авгусТ")); // 0
// Greek also works as long as there is no 1:M mapping in sight
writeln(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
writeln(icmp("ΐ", "\u03B9\u0308\u0301")); // 0
writeln(icmp("ΌΎ", "όύ")); // 0
Authors
Dmitry Olshansky
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.