Skip to content

Instantly share code, notes, and snippets.

@juliarose
Created March 1, 2023 10:57
Show Gist options
  • Save juliarose/72a141b93827fba02d24808697b71039 to your computer and use it in GitHub Desktop.
Save juliarose/72a141b93827fba02d24808697b71039 to your computer and use it in GitHub Desktop.
fn main() {
let mut s = String::with_capacity(100);
s.push_str("coffee and 🍌");
s.shrink_to_fit();
println!("`{s}` {} {}", s.len(), s.capacity());
for c in '0'..='🍌' {
if c.is_control() {
// exclude controls, they mess up the output
continue;
}
let mut buf = vec![0; c.len_utf8()];
c.encode_utf8(&mut buf);
println!("{c} {buf:?}", );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment