C# · Types

Types

using StringZilla; 6.0.0-rc.1 · 91a27bdd

API

ClassSzCore StringZilla operations: search, compare, hash, and memory primitives.42
StringZilla.cs:30 ↗
class Sz
SegmentKindA tiling segmentation: every byte lands in exactly one segment.
StringZilla.cs:216 ↗
enum SegmentKind

Values

Graphemes
Words
Sentences
LineBreaks
NormalFormUnicode normalization forms, NfkcCasefold being NFKC with full case folding and without default-ignorable codepoints, the Unicode toNFKC_Casefold that caseless keys match on.
StringZilla.cs:413 ↗
enum NormalForm

Values

Nfd0
Nfc1
Nfkd2
Nfkc3
NfkcCasefold4
IndexOfFirst byte offset of needle in haystack , or -1.
StringZilla.cs:36 ↗
long IndexOf(ReadOnlySpan<byte> haystack, ReadOnlySpan<byte> needle);
long IndexOf(ReadOnlySpan<byte> haystack, byte needle);

Like IndexOf(ReadOnlySpan<byte>, ReadOnlySpan<byte>), for a single byte: the first offset of needle , or -1.

Like System.MemoryExtensions.IndexOf<T>(System.ReadOnlySpan<T>,System.ReadOnlySpan<T>), SIMD-accelerated for large inputs. Keywords: find, search, substring, indexof.

LastIndexOfLike IndexOf(ReadOnlySpan<byte>, ReadOnlySpan<byte>) from the end: the last byte offset of needle , or -1.
StringZilla.cs:50 ↗
long LastIndexOf(
    ReadOnlySpan<byte> haystack,
    ReadOnlySpan<byte> needle);
long LastIndexOf(ReadOnlySpan<byte> haystack, byte needle);

Like LastIndexOf(ReadOnlySpan<byte>, ReadOnlySpan<byte>), for a single byte: the last offset of needle , or -1.

IndexOfAnyFirst offset of any byte present in set , or -1.
StringZilla.cs:85 ↗
long IndexOfAny(ReadOnlySpan<byte> haystack, ref Byteset set);
LastIndexOfAnyLast offset of any byte present in set , or -1.
StringZilla.cs:96 ↗
long LastIndexOfAny(ReadOnlySpan<byte> haystack, ref Byteset set);
EqualByte-wise equality.
StringZilla.cs:112 ↗
bool Equal(ReadOnlySpan<byte> a, ReadOnlySpan<byte> b);

Like System.MemoryExtensions.SequenceEqual<T>(System.ReadOnlySpan<T>,System.ReadOnlySpan<T>).

CompareLexicographic byte comparison: -1, 0, or 1.
StringZilla.cs:124 ↗
int Compare(ReadOnlySpan<byte> a, ReadOnlySpan<byte> b);

Like System.MemoryExtensions.SequenceCompareTo<T>(System.ReadOnlySpan<T>,System.ReadOnlySpan<T>).

HashFast 64-bit AES-based hash (SMHasher-quality), with optional seed .
StringZilla.cs:140 ↗
ulong Hash(ReadOnlySpan<byte> data, ulong seed = 0);

Unlike string.GetHashCode(), this is stable across runs/processes and identical across all StringZilla bindings. For cryptographic hashing use Sha256.

ByteSumSum of all byte values in data as an unsigned 64-bit integer.
StringZilla.cs:149 ↗
ulong ByteSum(ReadOnlySpan<byte> data);
CountRunesCounts Unicode scalar values (codepoints) in UTF-8 text .
StringZilla.cs:165 ↗
long CountRunes(ReadOnlySpan<byte> text);

Like counting System.Text.Runes, but SIMD-accelerated over UTF-8 bytes with no UTF-16 transcode. Keywords: codepoint, rune count, length.

CountRunes("你好世界"u8) is 4; CountRunes("Hello🌍"u8) is 6 — the astral emoji is a single scalar.

SeekRuneByte offset of the index -th codepoint (0-based), or -1 if fewer exist.
StringZilla.cs:174 ↗
long SeekRune(ReadOnlySpan<byte> text, long index);

Analogous to string.EnumerateRunes positioning, on UTF-8 bytes.

DecodeDecodes UTF-8 codepoints into destination (one Int32 scalar each; ill-formed or truncated sequences become U+FFFD).
StringZilla.cs:188 ↗
int Decode(ReadOnlySpan<byte> text, Span<int> destination);
int Decode(
    ReadOnlySpan<byte> text,
    Span<int> destination,
    out long bytesConsumed);

As Decode(System.ReadOnlySpan<byte>,System.Span<int>), also reporting how many input bytes were consumed so callers can resume.

Returns the count written, stopping early only when destination fills.

Like System.Text.Rune.DecodeFromUtf8 in bulk, SIMD-accelerated. Emitted values are valid Unicode scalars (incl. U+FFFD): wrap with new Rune(cp).

DecodeAllAllocates and returns all codepoints of text as Int32 scalars.
StringZilla.cs:205 ↗
int[] DecodeAll(ReadOnlySpan<byte> text);
SegmentWrites the byte lengths of the next segments of text into the caller's lengths and returns the count written.
StringZilla.cs:233 ↗
int Segment(
    ReadOnlySpan<byte> text,
    SegmentKind kind,
    Span<long> lengths);

Allocation-free. Segments tile the text, each starting where the previous one ended, so resume at the sum of the lengths; only an empty text yields 0.

Graphemes ≈ System.Globalization.StringInfo / System.Globalization.TextElementEnumerator; words/sentences/lines follow UAX-29 / UAX-14. SIMD-accelerated, deterministic, over UTF-8 bytes (no locale, no transcode). Keywords: grapheme, word break, sentence, line break, TextElement, BreakIterator.

Segmentation tiles the text — every byte lands in exactly one segment. By SegmentKind.Graphemes, the flag 🇺🇸 is one cluster spanning two codepoints and "e"+U+0301 (a decomposed é) is one cluster spanning two; by SegmentKind.Words, "Hello, 世界" splits the Latin run from the CJK run.

CaseFoldFolds into the caller's destination (must hold ≥ text.Length*3 bytes) and returns the bytes written.
StringZilla.cs:285 ↗
int CaseFold(ReadOnlySpan<byte> text, Span<byte> destination);
byte[] CaseFold(ReadOnlySpan<byte> text);

Full Unicode case folding (UAX #21, one-to-many, e.g.

Allocation-free.

UncasedIndexOfCase-insensitive (full-fold) search: byte offset of the first match, or -1; sets matchedLength (may differ from needle length due to folding).
StringZilla.cs:319 ↗
long UncasedIndexOf(
    ReadOnlySpan<byte> haystack,
    ReadOnlySpan<byte> needle,
    out long matchedLength);

Fills a gap: no .NET caseless UTF-8 substring search. For repeated searches with the same needle, prefer UncasedNeedle.

UncasedCompareCase-insensitive (full-fold) lexicographic comparison: -1, 0, or 1.
StringZilla.cs:346 ↗
int UncasedCompare(ReadOnlySpan<byte> a, ReadOnlySpan<byte> b);

Fills a gap: no .NET Unicode case-folded ordinal comparison.

HashMultiseedHashes data under each seed, writing results into hashes (must hold ≥ seeds.Length entries).
StringZilla.cs:361 ↗
void HashMultiseed(
    ReadOnlySpan<byte> data,
    ReadOnlySpan<ulong> seeds,
    Span<ulong> hashes);
ulong[] HashMultiseed(
    ReadOnlySpan<byte> data,
    ReadOnlySpan<ulong> seeds);

Allocating convenience: returns a fresh array of one hash per seed.

Allocation-free.

FillRandomFills buffer with deterministic pseudo-random bytes derived from nonce (AES-CTR-style; reproducible for the same nonce).
StringZilla.cs:384 ↗
void FillRandom(Span<byte> buffer, ulong nonce);
LookupByte-wise table transform: destination[i] = lut[source[i]].
StringZilla.cs:391 ↗
void Lookup(
    Span<byte> destination,
    ReadOnlySpan<byte> source,
    ReadOnlySpan<byte> lut);

lut must be exactly 256 bytes.

NormalizeNormalizes into the caller's destination (must hold ≥ text.Length*18 bytes) and returns the bytes written.
StringZilla.cs:417 ↗
int Normalize(
    ReadOnlySpan<byte> text,
    NormalForm form,
    Span<byte> destination);
byte[] Normalize(ReadOnlySpan<byte> text, NormalForm form);

Normalizes UTF-8 text to the given form.

Allocation-free.

IsNormalizedTrue if text is already in the given normalization form.
StringZilla.cs:451 ↗
bool IsNormalized(ReadOnlySpan<byte> text, NormalForm form);

Equivalent to string.IsNormalized(System.Text.NormalizationForm).

ArgSortWrites the sorting permutation of items into order (must hold ≥ items.Count entries) and returns the count of sorted indices (top if > 0, else items.Count).
StringZilla.cs:468 ↗
int ArgSort(
    IReadOnlyList<byte[]> items,
    Span<long> order,
    bool reverse = false,
    long top = 0,
    bool uncased = false);
long[] ArgSort(
    IReadOnlyList<byte[]> items,
    bool reverse = false,
    long top = 0,
    bool uncased = false);

Allocating convenience: returns a fresh permutation array.

int ArgSort(
    ReadOnlySpan<byte> text,
    ReadOnlySpan<long> starts,
    ReadOnlySpan<long> lengths,
    Span<long> order,
    bool reverse = false,
    long top = 0,
    bool uncased = false);

Sorts the segments of a single buffer in place — given per-segment starts and lengths (as produced by the split iterators), writes their sorting permutation into order and returns the count.

Allocation-free for the result.

Like System.Array.Sort(System.Array) with System.StringComparer.Ordinal, but returns indices and runs over UTF-8 bytes.

IntersectInner-joins two de-duplicated sequences, writing matching index pairs into firstPositions / secondPositions (each must hold ≥ min(a.Count, b.Count) entries) and returns the match count.
StringZilla.cs:541 ↗
int Intersect(
    IReadOnlyList<byte[]> a,
    IReadOnlyList<byte[]> b,
    Span<long> firstPositions,
    Span<long> secondPositions,
    ulong seed = 0);

Allocation-free for the result.

EnumerateRunesLazily enumerates the Unicode codepoints of text as System.Text.Runes (ill-formed sequences yield U+FFFD).
StringZilla.cs:587 ↗
RuneEnumerable EnumerateRunes(ReadOnlySpan<byte> text);

Like string.EnumerateRunes, over UTF-8 bytes; batches 64 per native call. Allocation-free; synchronous foreach only (the enumerator is a ref struct).

EnumerateWordsLazily enumerates UAX-29 word segments as byte-slice views (tiling; no empty segments).
StringZilla.cs:591 ↗
SegmentEnumerable EnumerateWords(ReadOnlySpan<byte> text);

Like iterating System.Globalization.StringInfo word elements, but over UTF-8 bytes.

EnumerateGraphemesLazily enumerates UAX-29 grapheme clusters as byte-slice views (tiling).
StringZilla.cs:595 ↗
SegmentEnumerable EnumerateGraphemes(ReadOnlySpan<byte> text);

Like System.Globalization.StringInfo.GetTextElementEnumerator(string), over UTF-8 bytes.

EnumerateSentencesLazily enumerates UAX-29 sentences as byte-slice views (tiling).
StringZilla.cs:598 ↗
SegmentEnumerable EnumerateSentences(ReadOnlySpan<byte> text);
EnumerateLineBreaksLazily enumerates UAX-14 line-break units as byte-slice views (tiling).
StringZilla.cs:601 ↗
SegmentEnumerable EnumerateLineBreaks(ReadOnlySpan<byte> text);
SplitLazily splits text on each occurrence of separator , yielding the segments between separators as byte-slice views.
StringZilla.cs:611 ↗
SplitEnumerable Split(
    ReadOnlySpan<byte> text,
    ReadOnlySpan<byte> separator);

Empty segments are kept by default (like string.Split(string[],System.StringSplitOptions)); chain .SkipEmpty(), .KeepSeparator(), or .WithMaxSplit(n) to change behaviour.

RSplitAs Split but scanning from the end; yields the last segment first.
StringZilla.cs:615 ↗
SplitEnumerable RSplit(
    ReadOnlySpan<byte> text,
    ReadOnlySpan<byte> separator);
SplitAnyLazily splits on any byte in separators (like splitting on a character set).
StringZilla.cs:619 ↗
SplitEnumerable SplitAny(ReadOnlySpan<byte> text, Byteset separators);
RSplitAnyAs SplitAny but scanning from the end.
StringZilla.cs:623 ↗
SplitEnumerable RSplitAny(ReadOnlySpan<byte> text, Byteset separators);
EnumerateMatchesLazily enumerates the byte offsets of every (non-overlapping) match of needle in haystack ; chain .Overlapping() for overlaps.
StringZilla.cs:630 ↗
MatchEnumerable EnumerateMatches(
    ReadOnlySpan<byte> haystack,
    ReadOnlySpan<byte> needle);

Counting the result is the occurrence count. An empty needle matches at every offset, the end included.

SplitNewlinesLazily splits on Unicode newline runs, yielding the lines between them.
StringZilla.cs:635 ↗
TokenSplitEnumerable SplitNewlines(ReadOnlySpan<byte> text);

Chain .WithSeparators() for a lossless interleave or .SkipEmpty() to drop blanks.

SplitWhitespacesLazily splits on Unicode whitespace runs, yielding the fields between them.
StringZilla.cs:639 ↗
TokenSplitEnumerable SplitWhitespaces(ReadOnlySpan<byte> text);
SplitDelimitersLazily splits on Unicode delimiter runs (punctuation/symbols/separators).
StringZilla.cs:643 ↗
TokenSplitEnumerable SplitDelimiters(ReadOnlySpan<byte> text);
EnumerateUncasedMatchesLazily enumerates case-insensitive (full-fold) matches of needle , yielding each match's offset and matched length (which may differ from the needle length due to folding, e.g.
StringZilla.cs:650 ↗
UncasedMatchEnumerable EnumerateUncasedMatches(
    ReadOnlySpan<byte> haystack,
    ReadOnlySpan<byte> needle);

"ß" matching "SS"). Chain .Overlapping() for overlapping matches. An empty needle matches at every codepoint boundary, the end included.

PartitionSplits at the first occurrence of separator into (before, separator, after) views; if absent, returns (text , empty, empty).
StringZilla.cs:655 ↗
Partition Partition(
    ReadOnlySpan<byte> text,
    ReadOnlySpan<byte> separator);
RPartitionAs Partition but at the last occurrence; if absent, returns (empty, empty, text ).
StringZilla.cs:663 ↗
Partition RPartition(
    ReadOnlySpan<byte> text,
    ReadOnlySpan<byte> separator);
CapabilitiesNameNames the capabilities in capabilities , comma-separated, like "serial,haswell".
StringZilla.cs:678 ↗
string CapabilitiesName(ulong capabilities);
StructBytesetA 256-bit set of byte values.5
StringZilla.cs:1283 ↗
struct Byteset
AddAdds value to the set.
StringZilla.cs:1287 ↗
void Add(byte value);
AddRangeAdds every byte of values to the set.
StringZilla.cs:1290 ↗
void AddRange(ReadOnlySpan<byte> values);
ContainsReturns true if value is in the set.
StringZilla.cs:1295 ↗
bool Contains(byte value);
InvertReplaces the set with its complement, so members become non-members and the reverse.
StringZilla.cs:1299 ↗
void Invert();
FromBytesCreates a set holding every byte of values .
StringZilla.cs:1304 ↗
Byteset FromBytes(ReadOnlySpan<byte> values);