Skip to content

Commit acf0591

Browse files
committed
feat: print ASCII code
1 parent 6e1475e commit acf0591

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/main.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() -> Result<()> {
1212
// read from stdin
1313
None => {
1414
let mut line = String::new();
15-
std::io::stdin().read_line(&mut line).unwrap();
15+
std::io::stdin().read_line(&mut line)?;
1616
line
1717
}
1818
};
@@ -25,17 +25,17 @@ fn parse_string(content: &str) -> Result<()> {
2525

2626
while let Some(b) = bytes.next() {
2727
if b & 0x80 == 0 {
28-
// if MSB is 0, is is ASCII.
28+
// if MSB is 0, is is just ASCII.
2929
println!(
30-
"{} {} {} (U+{:04X})",
30+
"{} {} {} (U+{:04X} ASCII={})",
3131
"├".bright_black(),
3232
format!("{:08b}", b).cyan(),
33-
std::str::from_utf8(&[b])
34-
.unwrap()
33+
std::str::from_utf8(&[b])?
3534
.replace("\x0a", "↵")
3635
.replace("\x20", "<space>")
3736
.bold(),
38-
b
37+
b,
38+
b,
3939
);
4040
} else {
4141
let nb = (!b).leading_zeros();

0 commit comments

Comments
 (0)