diff options
| author | Jokler <jokler.contact@gmail.com> | 2019-11-03 02:02:47 +0100 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2019-11-03 02:02:47 +0100 |
| commit | 9a86d647c520828ba8079870d05f159c1b3e9b52 (patch) | |
| tree | af218b6c2baf2274fc443420bb95b87080ed815c /src/plugins/unicode.rs | |
| parent | 02beaaa5c7c9ef9f8a3f20d7abe4e69a7c2ef982 (diff) | |
| download | frippy-9a86d647c520828ba8079870d05f159c1b3e9b52.tar.gz frippy-9a86d647c520828ba8079870d05f159c1b3e9b52.zip | |
Unicode: Hide bytes if there is only one
Diffstat (limited to 'src/plugins/unicode.rs')
| -rw-r--r-- | src/plugins/unicode.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/plugins/unicode.rs b/src/plugins/unicode.rs index 0bb3544..49e4a59 100644 --- a/src/plugins/unicode.rs +++ b/src/plugins/unicode.rs @@ -38,20 +38,26 @@ impl<C: FrippyClient> Unicode<C> { let mut buf = [0; 4]; - let byte_string = character + let bytes = character .encode_utf8(&mut buf) .as_bytes() .iter() .map(|b| format!("{:#x}", b)) - .collect::<Vec<String>>() - .join(","); + .collect::<Vec<String>>(); let name = self.get_name(character); - format!( - "{} is '{}' | UTF-8: {2:#x} ({2}), Bytes: [{3}]", - character, name, character as u32, byte_string - ) + if bytes.len() > 1 { + format!( + "{} is '{}' | UTF-8: {2:#x} ({2}), Bytes: [{3}]", + character, name, character as u32, bytes.join(",") + ) + } else { + format!( + "{} is '{}' | UTF-8: {2:#x} ({2})", + character, name, character as u32 + ) + } } } |
