#utf-16 #utf-8 #const

const-utf16

Utf8 to utf16 conversion functions for use in const contexts

5 releases

0.2.1 Mar 11, 2021
0.2.0 Feb 8, 2021
0.1.2 Feb 6, 2021
0.1.1 Feb 6, 2021
0.1.0 Feb 6, 2021

#1505 in Text processing

28 downloads per month
Used in 3 crates

Apache-2.0/MIT

9KB
146 lines

crates.io docs.rs Build and Test

const-utf16

utf8 to utf16 conversion functions useable in const contexts.

Use

const HELLO_WORLD_UTF16: &[u16] = const_utf16::encode!("Hello, world!");

Minimum Supported Rust Version (MSRV)

This crate requires Rust 1.46.0 or newer due to the use of some const expression features.

Attribution

This code is largely inspired by the Rust core utf16 conversion code.


lib.rs:

Const evaluated utf8 to utf16 conversion functions.

Use

const HELLO_WORLD_UTF16: &[u16] = const_utf16::encode!("Hello, world!");

No runtime deps