mirror of
https://github.com/openharmony/third_party_rust_unicode-width.git
synced 2026-07-19 15:13:40 -04:00
755 B
755 B
unicode_width
Determine displayed width of char and str types according to
Unicode Standard Annex #11
rules.
extern crate unicode_width;
use unicode_width::UnicodeWidthStr;
fn main() {
let teststr = "Hello, world!";
let width = UnicodeWidthStr::width(teststr);
println!("{}", teststr);
println!("The above string is {} columns wide.", width);
let width = teststr.width_cjk();
println!("The above string is {} columns wide (CJK).", width);
}