Type Definition odbc_api::U16String [−][src]
type U16String = UString<u16>;
Expand description
An owned, mutable “wide” string for FFI that is not nul-aware.
U16String is not aware of nul values. Strings may or may not be nul-terminated, and may
contain invalid and ill-formed UTF-16 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.
WideCString should be used instead if nul-aware strings are required.
U16String 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 U16String and shows how to convert a U16String to a
regular Rust String.
use widestring::U16String; let s = "Test"; // Create a wide string from the rust string let wstr = U16String::from_str(s); // Convert back to a rust string let rust_str = wstr.to_string_lossy(); assert_eq!(rust_str, "Test");