Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Displayed width of Unicode characters and strings according to UAX#11 rules.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

unicode-rs/unicode-width

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Determine displayed width ofchar andstr types according toUnicode Standard Annex #11 rules.

Build Status

Documentation

externcrate unicode_width;use unicode_width::UnicodeWidthStr;fnmain(){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);}

NOTE: The computed width values may not match the actual rendered columnwidth. For example, the woman scientist emoji comprises of a woman emoji, azero-width joiner and a microscope emoji.

externcrate unicode_width;use unicode_width::UnicodeWidthStr;fnmain(){assert_eq!(UnicodeWidthStr::width("👩"),2);// Womanassert_eq!(UnicodeWidthStr::width("🔬"),2);// Microscopeassert_eq!(UnicodeWidthStr::width("👩‍🔬"),4);// Woman scientist}

SeeUnicode Standard Annex #11 for precise details on what is and isn'tcovered by this crate.

features

unicode-width does not depend on libstd, so it can be used in crateswith the#![no_std] attribute.

crates.io

You can use this package in your project by adding the followingto yourCargo.toml:

[dependencies]unicode-width ="0.1.5"

About

Displayed width of Unicode characters and strings according to UAX#11 rules.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Contributors17


[8]ページ先頭

©2009-2025 Movatter.jp