diff --git a/Cargo.toml b/Cargo.toml index 50372c9..9256a47 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ascii_table" -version = "3.0.2" +version = "4.0.0-alpha" authors = ["Gerrit Viljoen "] license = "MIT" edition = "2018" @@ -15,3 +15,6 @@ keywords = ["ascii", "table"] [dev-dependencies] colorful = "0.2" + +[dependencies] +unicode-segmentation = "1.7.1" diff --git a/src/lib.rs b/src/lib.rs index 10abcf3..93276d6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,6 +58,8 @@ mod test; use std::collections::BTreeMap; use std::fmt::Display; +use unicode_segmentation::UnicodeSegmentation; + const SE: &str = "┌"; const NW: &str = "┘"; const SW: &str = "┐"; @@ -396,7 +398,7 @@ impl SmartString { fn char_len(&self) -> usize { self.fragments.iter() .filter(|(visible, _)| *visible) - .map(|(_, string)| string.chars().count()) + .map(|(_, string)| UnicodeSegmentation::graphemes(string.as_str(), true).count()) .sum() }