unicode width 16
1.0.0
هذا الصندوق هو شوكة من https://github.com/unicode-rs/unicode-width مع دعم Unicode 16 وتطبيع normalization .
حدد عرض أنواع char و str وفقًا لقواعد Unicode Standard Annex #11.
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
}راجع Unicode Standard Annex #11 للحصول على تفاصيل دقيقة حول ما هو وما لم يتم تغطيته بواسطة هذا الصندوق.
لا يعتمد Unicode-Width على libstd ، بحيث يمكن استخدامه في الصناديق مع سمة #![no_std] .
يمكنك استخدام هذه الحزمة في مشروعك عن طريق إضافة ما يلي إلى Cargo.toml :
[ dependencies ]
unicode-width-16 = " 0.1.0 "