[−][src]Macro wchar::wch_c
Generate a C-style nul-terminated UTF-16 wide string from the given string literal.
The generated output takes the form of a slice of wide characters
&'static [u16]
, with a nul-terminator as the last wide character.
Validations are made that the given string does not contain nul characters.
Examples
Basic example:
let wide_str = wch_c!("bar"); let expected = &[0x0062, 0x0061, 0x0072, 0x0000]; assert_eq!(wide_str, expected);
Raw literal example:
let wide_str = wch_c!(r#"%HOME%\foo\bar"#); let expected = &[ 0x0025, 0x0048, 0x004F, 0x004D, 0x0045, 0x0025, 0x005C, 0x0066, 0x006F, 0x006F, 0x005C, 0x0062, 0x0061, 0x0072, 0x0000, ]; assert_eq!(wide_str, expected);