Skip to main content

Module wc

Module wc 

Source

Structs§

WcCounts
Results from counting a byte slice.

Functions§

count_all
Count all metrics using optimized individual passes.
count_bytes
Count bytes. Trivial but included for API consistency.
count_chars
Count characters, choosing behavior based on locale.
count_chars_c
Count characters in C/POSIX locale (each byte is one character).
count_chars_parallel
Count UTF-8 characters in parallel.
count_chars_utf8
Count UTF-8 characters by counting non-continuation bytes. A continuation byte has the bit pattern 10xxxxxx (0x80..0xBF). Every other byte starts a new character (ASCII, multi-byte leader, or invalid).
count_lines
Count newlines using SIMD-accelerated memchr. GNU wc counts newline bytes (\n), not logical lines.
count_lines_parallel
Count newlines in parallel using SIMD memchr + rayon. Each thread gets at least 1MB (to amortize rayon scheduling overhead).
count_lines_words
Count lines and words using optimized strategies per locale. UTF-8: fused single-pass for lines+words to avoid extra data traversal. C locale: single scalar pass with 3-state logic and ASCII run skipping.
count_lines_words_chars
Count lines, words, and chars using optimized strategies per locale.
count_lwb
Count lines + words + bytes in a single fused pass (the default wc mode). Avoids separate passes entirely — combines newline counting with word detection.
count_lwb_parallel
Parallel counting of lines + words + bytes only (no chars). Optimized for the default wc mode: avoids unnecessary char-counting pass. C locale: single fused pass per chunk counts BOTH lines and words. UTF-8 with pure ASCII data: falls back to parallel C locale path.
count_lwc_parallel
Combined parallel counting of lines + words + chars.
count_words
Count words using locale-aware 3-state logic (default: UTF-8).
count_words_locale
Count words with explicit locale control using 3-state logic.
count_words_parallel
Count words in parallel with boundary adjustment.
is_utf8_locale
Detect if the current locale uses UTF-8 encoding.
max_line_length
Compute maximum display width, choosing behavior based on locale.
max_line_length_c
Compute maximum display width of any line (C/POSIX locale).
max_line_length_utf8
Compute maximum display width of any line (UTF-8 locale).