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
Changes to bin/rust/write-weird-unicode-data/main.rs. All files
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 {})+ }+}