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 with prefix.
If prefix == "" true is returned.
JS backend uses native String.prototype.startsWith.
Source Edit proc endsWith(s, suffix: cstring): bool {...}{.noSideEffect, gcsafe, extern: "csuEndsWith", raises: [], tags: [].}
-
Returns true if s ends with suffix.
If suffix == "" true is returned.
JS backend uses native String.prototype.endsWith.
Source Edit 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. use macros.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