220406.2 · 9a0d933b2fa328812232fbce0ddbeb0e19c9667b
bin: add 'write-weird-unicode-data'
I occasionally want to test things on weird data, so this tool is meant to generate it. Currently, it just writes all codepoints, but I'll likely expand it later.
reading declarations
bin/rust/write-weird-unicode-data/.gitignore
@@ -0,0 +1 @@+/target
bin/rust/write-weird-unicode-data/Cargo.lock
@@ -0,0 +1,49 @@+# This file is automatically @generated by Cargo.+# It is not intended for manual editing.+version = 3++[[package]]+name = "anyhow"+version = "1.0.32"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6b602bfe940d21c130f3895acd65221e8a61270debe89d628b9cb4e3ccb8569b"++[[package]]+name = "bitflags"+version = "1.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"++[[package]]+name = "clap"+version = "2.33.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"+dependencies = [+ "bitflags",+ "textwrap",+ "unicode-width",+]++[[package]]+name = "textwrap"+version = "0.11.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"+dependencies = [+ "unicode-width",+]++[[package]]+name = "unicode-width"+version = "0.1.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"++[[package]]+name = "write-weird-unicode-data"+version = "0.0.1"+dependencies = [+ "anyhow",+ "clap",+]
bin/rust/write-weird-unicode-data/Cargo.toml
@@ -0,0 +1,13 @@+[package]+name = "write-weird-unicode-data"+version = "0.0.1"+authors = ["Andrew Gallant <jamslam@gmail.com>"]+edition = "2018"++[[bin]]+name = "write-weird-unicode-data"+path = "main.rs"++[dependencies]+anyhow = "1.0.32"+clap = { version = "2.33.0", default-features = false }
bin/rust/write-weird-unicode-data/README.md
@@ -0,0 +1,2 @@+Currently this program just writes all Unicode codepoints to stdout. I might+extend it in the future to do more interesting things.
bin/rust/write-weird-unicode-data/main.rs
@@ -0,0 +1,39 @@+// Currently this program just writes all Unicode codepoints to stdout.++use std::io::{self, Write};++use anyhow::Context;++fn main() -> anyhow::Result<()> {+ let stdout = io::stdout();+ let mut bufwtr = io::BufWriter::new(stdout.lock());++ let _ = Args::parse()?;+ for cp in 0..=0x10FFFF {+ let ch = match char::from_u32(cp) {+ None => continue,+ Some(cp) => cp,+ };+ bufwtr+ .write_all(ch.encode_utf8(&mut [0; 4]).as_bytes())+ .context("failed to write to stdout")?;+ }+ Ok(())+}++#[derive(Debug)]+struct Args {}++impl Args {+ fn parse() -> anyhow::Result<Args> {+ use clap::{crate_authors, crate_version, App};++ let _ = App::new("Write weird Unicode data to stdout.")+ .author(crate_authors!())+ .version(crate_version!())+ .max_term_width(80)+ .get_matches();++ Ok(Args {})+ }+}
bin/rust/write-weird-unicode-data/rustfmt.toml
@@ -0,0 +1,2 @@+max_width = 79+use_small_heuristics = "max"