cstrutils
This module supports helper routines for working with cstring
without having to convert cstring
to string
in order to save allocations.
Procs
proc startsWith(s, prefix: cstring): bool {...}{.noSideEffect, gcsafe, extern: "csuStartsWith", raises: [], tags: [].}
-
Returns true if
s
starts withprefix
.If
prefix == ""
true is returned.JS backend uses native
Source EditString.prototype.startsWith
. proc endsWith(s, suffix: cstring): bool {...}{.noSideEffect, gcsafe, extern: "csuEndsWith", raises: [], tags: [].}
-
Returns true if
s
ends withsuffix
.If
suffix == ""
true is returned.JS backend uses native
Source EditString.prototype.endsWith
. proc cmpIgnoreStyle(a, b: cstring): int {...}{.noSideEffect, gcsafe, extern: "csuCmpIgnoreStyle", raises: [], tags: [].}
- Semantically the same as
cmp(normalize($a), normalize($b))
. It is just optimized to not allocate temporary strings. This should NOT be used to compare Nim identifier names. usemacros.eqIdent
for that. Returns:0 if a == b
< 0 if a < b
> 0 if a > bNot supported for JS backend, use strutils.cmpIgnoreStyle instead.
Source Edit proc cmpIgnoreCase(a, b: cstring): int {...}{.noSideEffect, gcsafe, extern: "csuCmpIgnoreCase", raises: [], tags: [].}
- Compares two strings in a case insensitive manner. Returns:
0 if a == b
< 0 if a < b
> 0 if a > bNot supported for JS backend, use strutils.cmpIgnoreCase instead.
Source Edit
© 2006–2021 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/cstrutils.html