Skip to content
/ wchar-rs Public

A procedural macro for compile time UTF-16 strings

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

Juici/wchar-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ed403de · Jun 28, 2024

History

68 Commits
Aug 9, 2021
Aug 9, 2021
Aug 9, 2021
Aug 9, 2021
Jul 22, 2019
Jun 28, 2024
Apr 16, 2021
Apr 16, 2021
Aug 9, 2021
Jun 28, 2024
Apr 16, 2021

Repository files navigation

wchar

build status crates.io docs.rs

This library introduces two macros to create UTF-16 and UTF-32 wide strings at compiler time, like L string literals in C.

[dependencies]
wchar = "0.10"

Compiler support: requires rustc 1.53+

Example

use wchar::{wch, wchz, wchar_t};

// Equivalent to `#define RUST L"Rust"` in C.
const RUST: &[wchar_t] = wch!("Rust\0"); // C strings are nul-terminated.
// Equivalent to `#define ALSO_RUST L"Rust"` in C.
const ALSO_RUST: &[wchar_t] = wchz!("Rust");

assert_eq!(RUST, &['R' as wchar_t, 'u' as wchar_t, 's' as wchar_t, 't' as wchar_t, 0x0000]);
assert_eq!(RUST, ALSO_RUST);

License

This project is licensed under either of Apache License, Version 2.0 or MIT License at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.