about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/core/src/bstr.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/library/core/src/bstr.rs b/library/core/src/bstr.rs
index 74e07f3d242..ae84fd8adb6 100644
--- a/library/core/src/bstr.rs
+++ b/library/core/src/bstr.rs
@@ -151,7 +151,9 @@ impl fmt::Display for ByteStr {
         };
         let nchars: usize = self
             .utf8_chunks()
-            .map(|chunk| chunk.valid().len() + if chunk.invalid().is_empty() { 0 } else { 1 })
+            .map(|chunk| {
+                chunk.valid().chars().count() + if chunk.invalid().is_empty() { 0 } else { 1 }
+            })
             .sum();
         let padding = f.width().unwrap_or(0).saturating_sub(nchars);
         let fill = f.fill();