Expand description
§Windows string types
The windows-strings crate provides common Windows string types used by various Windows APIs.
Start by adding the following to your Cargo.toml file:
[dependencies.windows-strings]
version = "0.2"
Use the Windows string types as needed:
use windows_strings::*;
const A: PCSTR = s!("ansi");
const W: PCWSTR = w!("wide");
fn main() {
let b = BSTR::from("bstr");
let h = HSTRING::from("hstring");
assert_eq!(b, "bstr");
assert_eq!(h, "hstring");
assert_eq!(unsafe { A.to_string().unwrap() }, "ansi");
assert_eq!(unsafe { W.to_string().unwrap() }, "wide");
}
Macros§
- A literal HSTRING, length-prefixed wide string with a trailing null terminator.
- A literal UTF-8 string with a trailing null terminator.
- A literal UTF-16 wide string with a trailing null terminator.
Structs§
- A BSTR string (BSTR) is a length-prefixed wide string.
- An (HSTRING) is a reference-counted and immutable UTF-16 string type.
- An HSTRING builder that supports preallocating the
HSTRING
to avoid extra allocations and copies. - A pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters.
- A pointer to a constant null-terminated string of 16-bit Unicode characters.
- A pointer to a null-terminated string of 8-bit Windows (ANSI) characters.
- A pointer to a null-terminated string of 16-bit Unicode characters.