aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJokler <jokler.contact@gmail.com>2019-11-03 02:02:47 +0100
committerJokler <jokler.contact@gmail.com>2019-11-03 02:02:47 +0100
commit9a86d647c520828ba8079870d05f159c1b3e9b52 (patch)
treeaf218b6c2baf2274fc443420bb95b87080ed815c /src
parent02beaaa5c7c9ef9f8a3f20d7abe4e69a7c2ef982 (diff)
downloadfrippy-9a86d647c520828ba8079870d05f159c1b3e9b52.tar.gz
frippy-9a86d647c520828ba8079870d05f159c1b3e9b52.zip
Unicode: Hide bytes if there is only one
Diffstat (limited to 'src')
-rw-r--r--src/plugins/unicode.rs20
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
+ )
+ }
}
}