Created
October 31, 2022 14:42
-
-
Save wperron/066621c73725e905f1c8cbb2f45879af to your computer and use it in GitHub Desktop.
print the printable portion of ascii character space
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::{self, Write}; | |
fn main() { | |
write_ascii(std::io::stdout()).unwrap(); | |
} | |
fn write_ascii<W: Write>(mut w: W) -> Result<(), io::Error> { | |
let chars = (0x20 as u8..0x7e + 1 as u8) | |
.into_iter() | |
.map(|b| char::from(b)) | |
.collect::<Vec<char>>(); | |
for c in chars.chunks(16) { | |
write!(w, "{}\n", c.iter().collect::<String>())? | |
} | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment