Trait unicode_width::UnicodeWidthStr

source ·
pub trait UnicodeWidthStr {
    // Required methods
    fn width(&self) -> usize;
    fn width_cjk(&self) -> usize;
}
Expand description

Methods for determining displayed width of Unicode strings.

Required Methods§

source

fn width(&self) -> usize

Returns the string’s displayed width in columns.

Control characters are treated as having zero width, and emoji presentation sequences are assigned width 2.

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.

source

fn width_cjk(&self) -> usize

Returns the string’s displayed width in columns.

Control characters are treated as having zero width, and emoji presentation sequences are assigned width 2.

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.

Implementations on Foreign Types§

source§

impl UnicodeWidthStr for str

source§

fn width(&self) -> usize

source§

fn width_cjk(&self) -> usize

Implementors§