#utf-16 #compile-time #proc-macro #string #string-literal #wide

wchar

Procedural macros for compile time UTF-16 and UTF-32 wide strings

12 releases (7 breaking)

0.11.1 Jun 28, 2024
0.11.0 Aug 9, 2021
0.10.1 May 14, 2021
0.6.1 Aug 27, 2020
0.2.0 Jun 25, 2018

#158 in Text processing

Download history 2645/week @ 2024-07-23 3376/week @ 2024-07-30 3200/week @ 2024-08-06 2133/week @ 2024-08-13 2745/week @ 2024-08-20 4118/week @ 2024-08-27 3511/week @ 2024-09-03 3742/week @ 2024-09-10 2929/week @ 2024-09-17 3924/week @ 2024-09-24 2676/week @ 2024-10-01 3327/week @ 2024-10-08 4612/week @ 2024-10-15 2783/week @ 2024-10-22 3336/week @ 2024-10-29 4570/week @ 2024-11-05

16,090 downloads per month
Used in 7 crates

MIT/Apache

20KB
342 lines

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.

Dependencies

~1.5MB
~37K SLoC