Crate wchar[−][src]
A procedural macro for compile time UTF-16 wide strings.
This crate introduces two macros wch!
and wch_c!
to create UTF-16
wide strings at compiler time, like the L
literal in C.
In order to use the macro the proc_macro
and proc_macro_non_items
features must be enabled.
Examples
#![feature(proc_macro, proc_macro_non_items)] extern crate wchar; use wchar::{wch, wch_c}; // Equivalent to `#define RUST L"Rust"` in C. const RUST: &[u16] = wch!("Rust\0"); // C strings are null-terminated. assert_eq!(RUST, &[0x0052, 0x0075, 0x0073, 0x0074, 0x0000]); // Equivalent to `#define ALSO_RUST L"Rust"` in C. const ALSO_RUST: &[u16] = wch_c!("Rust"); assert_eq!(ALSO_RUST, &[0x0052, 0x0075, 0x0073, 0x0074, 0x0000]);
Functions
wch |
Generate a UTF-16 wide string from the given string literal. |
wch_c |
Generate a C-style nul-terminated UTF-16 wide string from the given string literal. |