pub fn mb_strimwidth(s: &[u8], width: usize) -> Cow<'_, [u8]>Expand description
PHP mb_strimwidth($string, 0, $width) (no trim marker): the longest
leading part of the string that fits in width columns. A string that
fits is returned as it is, except that invalid sequences become ?, as
they do in a cut one.
use php_std::mb::mb_strimwidth;
assert_eq!(mb_strimwidth("你好".as_bytes(), 3).as_ref(), "你".as_bytes());
assert_eq!(mb_strimwidth(b"abc", 5).as_ref(), b"abc");
assert_eq!(mb_strimwidth(b"abc\xff\xfedef", 5).as_ref(), b"abc??");