pub trait OsStrExt { fn encode_wide(&self) -> EncodeWide<'_>ⓘNotable traits for EncodeWide<'a>impl<'a> Iterator for EncodeWide<'a> type Item = u16;; }
Windows-specific extensions to OsStr
.
fn encode_wide(&self) -> EncodeWide<'_>ⓘNotable traits for EncodeWide<'a>
impl<'a> Iterator for EncodeWide<'a>
type Item = u16;
Re-encodes an OsStr
as a wide character sequence, i.e., potentially ill-formed UTF-16.
This is lossless: calling OsStringExt::from_wide
and then encode_wide
on the result will yield the original code units. Note that the encoding does not add a final null terminator.
use std::ffi::OsString; use std::os::windows::prelude::*; // UTF-16 encoding for "Unicode". let source = [0x0055, 0x006E, 0x0069, 0x0063, 0x006F, 0x0064, 0x0065]; let string = OsString::from_wide(&source[..]); let result: Vec<u16> = string.encode_wide().collect(); assert_eq!(&source[..], &result[..]);
impl OsStrExt for OsStr
[src]
fn encode_wide(&self) -> EncodeWide<'_>ⓘNotable traits for EncodeWide<'a>
impl<'a> Iterator for EncodeWide<'a>
type Item = u16;
[src]
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/os/windows/ffi/trait.OsStrExt.html