#wide #string #wchar #utf16

wchar

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

11 releases (7 breaking)

0.11.0 Aug 9, 2021
0.10.1 May 14, 2021
0.9.0 May 12, 2021
0.6.1 Aug 27, 2020
0.2.0 Jun 25, 2018

#384 in Text processing

Download history 6374/week @ 2022-12-02 4885/week @ 2022-12-09 4514/week @ 2022-12-16 4024/week @ 2022-12-23 4331/week @ 2022-12-30 4637/week @ 2023-01-06 5313/week @ 2023-01-13 6364/week @ 2023-01-20 4921/week @ 2023-01-27 4485/week @ 2023-02-03 5159/week @ 2023-02-10 4686/week @ 2023-02-17 5355/week @ 2023-02-24 4416/week @ 2023-03-03 5272/week @ 2023-03-10 3404/week @ 2023-03-17

19,083 downloads per month
Used in 8 crates (7 directly)

MIT/Apache

18KB
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

~0.7–1MB
~27K SLoC