summaryrefslogtreecommitdiffstats
path: root/src/format.rs
diff options
context:
space:
mode:
authorPierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com>2016-09-12 11:30:09 +0200
committerPierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com>2016-09-12 11:30:09 +0200
commit3a8e694c8754c3ce2cdf842b56bee6e02fe14b71 (patch)
tree365c094077767664f3a5535134091178d8084668 /src/format.rs
parent7ea0205b9546da5b4754d79641a68605a72dd3b8 (diff)
Fixed wrong formatting of unicode separators
Diffstat (limited to 'src/format.rs')
-rw-r--r--src/format.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/format.rs b/src/format.rs
index d0d816e..49e1a96 100644
--- a/src/format.rs
+++ b/src/format.rs
@@ -1,6 +1,8 @@
//! Define table formatting utilities
-use std::io::{Write, Error};
+use std::io::{Write, Error};
+
+use encode_unicode::Utf8Char;
use super::utils::NEWLINE;
@@ -53,17 +55,19 @@ impl LineSeparator {
/// Print a full line separator to `out`. `col_width` is a slice containing the width of each column
pub fn print<T: Write+?Sized>(&self, out: &mut T, col_width: &[usize], colsep: bool, lborder: bool, rborder: bool) -> Result<(), Error> {
if lborder {
- try!(out.write_all(&[self.ljunc as u8]));
+ try!(out.write_all(Utf8Char::from(self.ljunc).as_bytes()));
}
let mut iter = col_width.into_iter().peekable();
while let Some(width) = iter.next() {
- try!(out.write_all(&vec![self.line as u8; width+2]));
+ for _ in 0..width+2 {
+ try!(out.write_all(Utf8Char::from(self.line).as_bytes()));
+ }
if colsep && iter.peek().is_some() {
- try!(out.write_all(&[self.junc as u8]));
+ try!(out.write_all(Utf8Char::from(self.junc).as_bytes()));
}
}
if rborder {
- try!(out.write_all(&[self.rjunc as u8]));
+ try!(out.write_all(Utf8Char::from(self.rjunc).as_bytes()));
}
out.write_all(NEWLINE)
}
@@ -185,7 +189,7 @@ impl TableFormat {
/// Print a column separator or a table border
pub fn print_column_separator<T: Write+?Sized>(&self, out: &mut T, pos: ColumnPosition) -> Result<(), Error> {
match self.get_column_separator(pos) {
- Some(s) => out.write_all(&[s as u8]),
+ Some(s) => out.write_all(Utf8Char::from(s).as_bytes()),
None => Ok(())
}
}