unicode width 16
1.0.0
이 상자는 유니 코드 16 지원 및 제거 된 normalization 가진 https://github.com/unicode-rs/unicode-width의 포크입니다 .
유니 코드 표준 부록 #11 규칙에 따라 표시된 char 및 str 유형의 너비를 결정하십시오.
use unicode_width_16 :: 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 ) ;
}참고 : 계산 된 너비 값은 실제 렌더링 된 열 너비와 일치하지 않을 수 있습니다. 예를 들어, 여성 과학자 이모티콘은 여성 이모티콘, 제로 폭 결합기 및 현미경 이모티콘으로 구성됩니다.
use unicode_width_16 :: UnicodeWidthStr ;
fn main ( ) {
assert_eq ! ( UnicodeWidthStr ::width ( "?" ) , 2 ) ; // Woman
assert_eq ! ( UnicodeWidthStr ::width ( "?" ) , 2 ) ; // Microscope
assert_eq ! ( UnicodeWidthStr ::width ( "??" ) , 4 ) ; // Woman scientist
}이 상자에 의해 다루지 않는 것에 대한 정확한 세부 사항은 유니 코드 표준 부록 #11을 참조하십시오.
Unicode-Width는 libstd에 의존하지 않으므로 #![no_std] 속성과 함께 상자에 사용할 수 있습니다.
Cargo.toml 에 다음을 추가하여 프로젝트 에서이 패키지를 사용할 수 있습니다.
[ dependencies ]
unicode-width-16 = " 0.1.0 "