sanitize-filename-reader-friendly

Crates.iosanitize-filename-reader-friendly
lib.rssanitize-filename-reader-friendly
version2.3.0
created_at2020-03-21 20:13:38.314438+00
updated_at2025-05-06 04:26:54.24905+00
descriptionA filename sanitizer aiming to produce reader friendly filenames.
homepagehttps://gitlab.com/getreu/sanitize-filename-reader-friendly
repositoryhttps://gitlab.com/getreu/sanitize-filename-reader-friendly
max_upload_size
id221062
size30,435
Jens Getreu (getreu)

documentation

README

sanitize-filename-reader-friendly

A filename sanitizer aiming to produce reader friendly filenames, while preserving as much information as possible.

Cargo Documentation License

Unlike Node's sanitize-filename, this library replaces non-file-system-compatible characters with underscore and space. Both are trimmed when they appear at the beginning or at the end of a line or when they repeat within. Non-printable punctuation marks are replaced by underscores, other non-printable characters by spaces, except the non-printable space U+200b which is filtered out. Newlines are replaced by dashes.

Sample usage:

extern crate sanitize_filename_reader_friendly;
use crate::sanitize_filename_reader_friendly::sanitize;

fn main() {
    println!("{}",
        sanitize("Read: http://blog.getreu.net/projects/tp-note/"));
    // Prints: "Read_ http_blog.getreu.net_projects_tp-note"
}

This library comes with a simple command-line application. Usage:

cargo install sanitize-filename-reader-friendly
sanitize-filename <input.txt >output.txt
Commit count: 35

cargo fmt