widestring 0.2.1

A wide string FFI library for converting to and from Windows Wide "Unicode" (UTF-16) strings.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
#![cfg(windows)]

use std::ffi::{OsString, OsStr};
use std::os::windows::ffi::{OsStringExt, OsStrExt};

pub fn os_to_wide(s: &OsStr) -> Vec<u16> {
    s.encode_wide().collect()
}

pub fn os_from_wide(s: &[u16]) -> OsString {
    OsString::from_wide(s)
}