Closed nrc closed 9 years ago
rustc_unicode::str::utf8_char_width
is still there, though it's behind the unicode
feature gate. I don't think there are any plans to deprecate utf8_char_width
in librustc_unicode, since it has to do with UTF-8 representation, not Unicode semantics. I'll inquire.
More to the point, though: it's not really possible to implement UnicodeWidthChar for u8 (though I suppose it is for u32, or for &[u8]). The two senses of "width" (width()
vs utf8_char_width()
) are not the same. The former has to do with how many displayed columns a character takes up; the latter has to do with how many bytes it takes to represent a character in UTF-8.
@kwantam libunicode is gone from the distro. It does look like it is the wrong kind of width though. I should look in one of the other unicode libs.
libunicode is renamed librustc_unicode. The following works on the 4/20 nightly:
#![feature(unicode)]
extern crate rustc_unicode;
use rustc_unicode::str as ustr;
fn main() {
for i in (0 .. 256) {
print!("{} ", ustr::utf8_char_width(i as u8));
}
println!("");
}
To replace the old
unicode::str::utf8_char_width