simdutf8-cli 0.2.7

SIMD-accelerated UTF-8 validation CLI built on the simdutf8 crate, with hardened path handling.
Documentation
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2025,2026 ndaal Gesellschaft für Sicherheit in der Informationstechnik mbH & Co KG, Cologne
// SPDX-FileCopyrightText: Author: Pierre Gronau <Pierre.Gronau@ndaal.eu>

//! Minimal example of using the `simdutf8_cli` library directly.
//!
//! Run with: `cargo run --example validate_bytes`

#![forbid(unsafe_code)]

use std::io::{self, Write};

use simdutf8_cli::validate::{validate, Validity};

fn main() -> io::Result<()> {
    // (label, bytes) pairs spanning several encodings.
    let samples: [(&str, &[u8]); 4] = [
        ("valid UTF-8", "grüße 😊".as_bytes()),
        ("UTF-16LE w/ BOM", &[0xFF, 0xFE, 0x48, 0x00, 0x69, 0x00]),
        ("Latin-1 'é'", b"caf\xE9"),
        ("truncated UTF-8", b"abc\xF0"),
    ];

    let stdout = io::stdout();
    let mut out = stdout.lock();

    for (label, bytes) in samples {
        match validate(bytes) {
            Validity::Valid => writeln!(out, "{label:18} -> valid")?,
            Validity::Invalid {
                valid_up_to,
                error_len,
            } => writeln!(
                out,
                "{label:18} -> invalid (valid_up_to={valid_up_to}, error_len={error_len:?})"
            )?,
        }
    }

    Ok(())
}