From ba1049365e1f2abb49293898930499387d678d0e Mon Sep 17 00:00:00 2001 From: kjuulh Date: Tue, 16 Dec 2025 11:12:38 +0100 Subject: [PATCH] feat: add mise and license --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ mise.toml | 6 ++++++ src/main.rs | 9 +++++++++ 3 files changed, 63 insertions(+) create mode 100644 README.md create mode 100644 mise.toml diff --git a/README.md b/README.md new file mode 100644 index 0000000..9823a4c --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# fexcel + +A simple command-line tool to sanitize invalid UTF-8 sequences from input streams. + +## Overview + +`fexcel` reads data from stdin, replaces any invalid UTF-8 sequences with the Unicode replacement character (�), and writes the sanitized output to stdout. This is particularly useful when working with files that may contain mixed or invalid encodings, such as Windows-exported CSV files. + +## Installation + +```bash +mise run install # or +cargo install --path . --force +``` + +Or build from source: + +```bash +cargo build --release +``` + +The binary will be available at `target/release/fexcel`. + +## Usage + +Use `fexcel` as a pipe filter to clean input before passing it to tools that require valid UTF-8: + +```bash +cat my-windows-exported.csv | fexcel | csvlens +``` + +Without `fexcel`, tools like `csvlens` may fail with invalid UTF-8 errors. By piping through `fexcel` first, you can safely view and process files with encoding issues. + +### Additional Examples + +Clean a file and save the output: +```bash +cat problematic-file.txt | fexcel > cleaned-file.txt +``` + +Use with any UTF-8 sensitive tool: +```bash +cat messy-data.log | fexcel | grep "pattern" +``` + +## License + +See LICENSE file for details. diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..e5afba4 --- /dev/null +++ b/mise.toml @@ -0,0 +1,6 @@ +[tools] +rust = { version = "1.91", components = "rust-src" } +cargo = "latest" + +[tasks.install] +run = "cargo install --path . --force" diff --git a/src/main.rs b/src/main.rs index dfcd1ec..366de8b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,12 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return Kasper J. Hermansen + * ---------------------------------------------------------------------------- + */ + use std::io::{Read, Write}; use anyhow::Context;