pub struct U16StrLe<'a>(pub &'a [u8]);
Expand description
Byte slice treated as a serialized UTF-16 (little-endian) string.
UTF-16 little-endian is the on-disk format that Windows uses for almost all strings.
U16StrLe
allows to work with this format directly without creating a copy or performing a conversion first.
The encoding is expected to be UTF-16 (or the UCS-2 subset for Windows NT 4.0 and earlier). However, this type will happily accept any byte, and only cares about the encoding when converting or displaying.
Tuple Fields§
§0: &'a [u8]
Implementations§
source§impl<'a> U16StrLe<'a>
impl<'a> U16StrLe<'a>
sourcepub const fn len(&self) -> usize
pub const fn len(&self) -> usize
Returns the length of self
.
This length is in bytes, not characters! In other words, it may not be what a human considers the length of the string.
sourcepub fn to_string(&self) -> Result<String>
Available on crate feature alloc
only.
pub fn to_string(&self) -> Result<String>
alloc
only.Attempts to copy self
to a new owned String
.
Returns Ok(String)
if all characters could be converted successfully or DecodeUtf16Error
otherwise.
sourcepub fn to_string_lossy(&self) -> String
Available on crate feature alloc
only.
pub fn to_string_lossy(&self) -> String
alloc
only.Copies self
to a new owned String
, replacing invalid data with the replacement character (U+FFFD).
sourcepub fn to_ustring(&self) -> U16String
Available on crate feature alloc
only.
pub fn to_ustring(&self) -> U16String
alloc
only.Copies self
to a new owned widestring::U16String
.
Trait Implementations§
source§impl<'a> Ord for U16StrLe<'a>
impl<'a> Ord for U16StrLe<'a>
source§impl<'a> PartialEq<&str> for U16StrLe<'a>
impl<'a> PartialEq<&str> for U16StrLe<'a>
source§impl<'a> PartialEq<U16StrLe<'a>> for &str
impl<'a> PartialEq<U16StrLe<'a>> for &str
source§impl<'a> PartialEq<U16StrLe<'a>> for str
impl<'a> PartialEq<U16StrLe<'a>> for str
source§impl<'a> PartialOrd<&str> for U16StrLe<'a>
impl<'a> PartialOrd<&str> for U16StrLe<'a>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a> PartialOrd<U16StrLe<'a>> for &str
impl<'a> PartialOrd<U16StrLe<'a>> for &str
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<U16StrLe<'a>> for U16StrLe<'b>
impl<'a, 'b> PartialOrd<U16StrLe<'a>> for U16StrLe<'b>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a> PartialOrd<U16StrLe<'a>> for str
impl<'a> PartialOrd<U16StrLe<'a>> for str
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a> PartialOrd<str> for U16StrLe<'a>
impl<'a> PartialOrd<str> for U16StrLe<'a>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more