Trait std::os::windows::ffi::OsStrExt 1.0.0[−][src]
pub trait OsStrExt: Sealed { fn encode_wide(&self) -> EncodeWide<'_>ⓘ; }Notable traits for EncodeWide<'a>impl<'a> Iterator for EncodeWide<'a> type Item = u16;
This is supported on Windows only.
Expand description
Windows 特定于 OsStr
的扩展。
trait 是密封的: 不能在标准库之外实现。 这是为了将来的附加方法不会破坏更改。
Required methods
fn encode_wide(&self) -> EncodeWide<'_>ⓘNotable traits for EncodeWide<'a>impl<'a> Iterator for EncodeWide<'a> type Item = u16;
[src]
fn encode_wide(&self) -> EncodeWide<'_>ⓘNotable traits for EncodeWide<'a>impl<'a> Iterator for EncodeWide<'a> type Item = u16;
[src]Notable traits for EncodeWide<'a>
impl<'a> Iterator for EncodeWide<'a> type Item = u16;
将 OsStr
重新编码为宽字符序列,即可能格式不正确的 UTF-16。
这是无损的: 在结果上调用 OsStringExt::from_wide
,然后调用 encode_wide
,将产生原始代码单元。
请注意,编码不会添加最终的空终止符。
Examples
use std::ffi::OsString; use std::os::windows::prelude::*; // UTF-16 "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[..]);Run
Implementors
fn encode_wide(&self) -> EncodeWide<'_>ⓘNotable traits for EncodeWide<'a>impl<'a> Iterator for EncodeWide<'a> type Item = u16;
[src]Notable traits for EncodeWide<'a>
impl<'a> Iterator for EncodeWide<'a> type Item = u16;