# cstrutils

- Manual
- Standard library
- Index

Search:
Group by:

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 iff `s` starts with `prefix`.

  If `prefix == ""` true is returned.

  Source Edit

    proc endsWith(s, suffix: cstring): bool {...}{.noSideEffect, gcsafe, extern: "csuEndsWith",
                                         raises: [], tags: [].}

  Returns true iff `s` ends with `suffix`.

  If `suffix == ""` true is returned.

  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 iff a == b
  < 0 iff a < b
  > 0 iff a > b

  Source Edit

    proc cmpIgnoreCase(a, b: cstring): int {...}{.noSideEffect, gcsafe,
                                        extern: "csuCmpIgnoreCase", raises: [], tags: [].}

  Compares two strings in a case insensitive manner. Returns:

  0 iff a == b
  < 0 iff a < b
  > 0 iff a > b

  Source Edit