Type Definition widestring::U32CString [−][src]
type U32CString = UCString<u32>;
An owned, mutable C-style wide string for FFI that is nul-aware and nul-terminated.
U32CString
is aware of nul values. Unless unchecked conversions are used, all U32CString
strings end with a nul-terminator in the underlying buffer and contain no internal nul values.
The strings may still contain invalid or ill-formed UTF-32 data. These strings are intended to
be used with FFI functions such as Windows API that may require nul-terminated strings.
U32CString
can be converted to and from many other string types, including U32String
,
OsString
, and String
, making proper Unicode FFI safe and easy.
Examples
The following example constructs a U32CString
and shows how to convert a U32CString
to a
regular Rust String
.
use widestring::U32CString; let s = "Test"; // Create a wide string from the rust string let wstr = U32CString::from_str(s).unwrap(); // Convert back to a rust string let rust_str = wstr.to_string_lossy(); assert_eq!(rust_str, "Test");