Trait unicode_width::UnicodeWidthStr [] [src]

pub trait UnicodeWidthStr {
    fn width<'a>(&'a self) -> usize;
    fn width_cjk<'a>(&'a self) -> usize;
}

Methods for determining displayed width of Unicode strings.

Required Methods

fn width<'a>(&'a self) -> usize

Returns the string's displayed width in columns.

Control characters are treated as having zero width.

This function treats characters in the Ambiguous category according to Unicode Standard Annex #11 as 1 column wide. This is consistent with the recommendations for non-CJK contexts, or when the context cannot be reliably determined.

fn width_cjk<'a>(&'a self) -> usize

Returns the string's displayed width in columns.

Control characters are treated as having zero width.

This function treats characters in the Ambiguous category according to Unicode Standard Annex #11 as 2 column wide. This is consistent with the recommendations for CJK contexts.

Implementors