fn string_from_utf16(data: &[u8]) -> crate::Result<String> {
    if data.len() < 2 {
        return Err(Error::new(
            ErrorKind::StringDecoding(data.to_vec()),
            "data is not valid utf16",
        ));
    }
    if data[0] == 0xFF && data[1] == 0xFE {
        string_from_utf16le(&data[2..])
    } else {
        string_from_utf16be(&data[2..])
    }
}
/// Returns a string created from the vector using UTF-16 (with byte order mark) encoding.
Returns a string created from the vector using UTF-16 (with byte order mark) encoding.
Returns a string created from the vector using UTF - 16 ( with byte order mark ) encoding .
fn string_from_utf16(data: &[u8]) -> crate::Result<String> {
    if data.len() < 2 {
        return Err(Error::new(
            ErrorKind::StringDecoding(data.to_vec()),
            "data is not valid utf16",
        ));
    }
    if data[0] == 0xFF && data[1] == 0xFE {
        string_from_utf16le(&data[2..])
    } else {
        string_from_utf16be(&data[2..])
    }
}
fn string_from_utf16 ( data : & [ u8 ] ) -> crate :: Result < String > { if data . len ( ) < 2 { return Err ( Error :: new ( ErrorKind :: StringDecoding ( data . to_vec ( ) ) , " " , ) ) ; } if data [ 0 ] == 0xFF && data [ 1 ] == 0xFE { string_from_utf16le ( & data [ 2 .. ] ) } else { string_from_utf16be ( & data [ 2 .. ] ) } }
Returns a string created from the vector using UTF-16 (with byte order mark) encoding.
Returns a string created from the vector using UTF - 16 ( with byte order mark ) encoding .
data
&[u8]
data
&[u8]