[][src]Macro wchar::wch

macro_rules! wch {
    #[proc_macro_hack] => { ... };
}

Generate a UTF-16 wide string from the given string literal.

The generated output takes the form of a slice of wide characters &'static [u16].

Whilst wch! can be used for C-style nul-terminated wide strings, no validations are made about internal nul characters. For more complex use cases it is recommended to use wch_c!.

Examples

Basic example:

let wide_str = wch!("foo");
let expected = &[0x0066, 0x006F, 0x006F];

assert_eq!(wide_str, expected);

Nul-terminated example:

let wide_str = wch!("bar\0");
let expected = &[0x0062, 0x0061, 0x0072, 0x0000];

assert_eq!(wide_str, expected);