Type Definition widestring::U32String [−][src]
type U32String = UString<u32>;
An owned, mutable 32-bit wide string for FFI that is not nul-aware.
U32String
is not aware of nul values. Strings may or may not be nul-terminated, and may
contain invalid and ill-formed UTF-32 data. These strings are intended to be used with
FFI functions that directly use string length, where the strings are known to have proper
nul-termination already, or where strings are merely being passed through without modification.
U32CString
should be used instead if nul-aware 32-bit strings are required.
U32String
can be converted to and from many other standard Rust string types, including
OsString
and String
, making proper Unicode FFI safe and easy.
Examples
The following example constructs a U32String
and shows how to convert a U32String
to a
regular Rust String
.
use widestring::U32String; let s = "Test"; // Create a wide string from the rust string let wstr = U32String::from_str(s); // Convert back to a rust string let rust_str = wstr.to_string_lossy(); assert_eq!(rust_str, "Test");