#unicode #iteration #utilities #unicode-text #text

unic-char-basics

UNIC — Unicode Character Tools — Basic Stable Character Properties

2 unstable releases

0.9.0 Mar 3, 2019
0.8.0 Jan 2, 2019

#39 in #iteration

Download history 55/week @ 2024-07-22 78/week @ 2024-07-29 116/week @ 2024-08-05 142/week @ 2024-08-12 293/week @ 2024-08-19 90/week @ 2024-08-26 105/week @ 2024-09-02 132/week @ 2024-09-09 128/week @ 2024-09-16 198/week @ 2024-09-23 136/week @ 2024-09-30 99/week @ 2024-10-07 137/week @ 2024-10-14 144/week @ 2024-10-21 139/week @ 2024-10-28 172/week @ 2024-11-04

598 downloads per month
Used in 5 crates (2 directly)

MIT/Apache

17KB
164 lines

UNIC — Unicode Character Tools — Basic Stable Character Properties

Crates.io Documentation

This UNIC component provides basic Unicode Character properties that are core to string processing and are stabilized by The Unicode Standard and will never change in the future.


lib.rs:

UNIC — Unicode Character Tools — Basic Stable Character Properties

A simple way to control iteration over a range of characters.

Examples

extern crate unic_char_basics;
use unic_char_basics::{is_noncharacter, is_private_use};

// Plane 0 (BMP)
assert_eq!(is_noncharacter('\u{0}'), false);
assert_eq!(is_noncharacter('\u{80}'), false);
assert_eq!(is_noncharacter('\u{e000}'), false);
assert_eq!(is_noncharacter('\u{f8ff}'), false);
assert_eq!(is_noncharacter('\u{fdd0}'), true);
assert_eq!(is_noncharacter('\u{fdef}'), true);
assert_eq!(is_noncharacter('\u{fffd}'), false);
assert_eq!(is_noncharacter('\u{fffe}'), true);
assert_eq!(is_noncharacter('\u{ffff}'), true);

assert_eq!(is_private_use('\u{0}'), false);
assert_eq!(is_private_use('\u{80}'), false);
assert_eq!(is_private_use('\u{e000}'), true);
assert_eq!(is_private_use('\u{f8ff}'), true);
assert_eq!(is_private_use('\u{fdd0}'), false);
assert_eq!(is_private_use('\u{fdef}'), false);
assert_eq!(is_private_use('\u{fffd}'), false);
assert_eq!(is_private_use('\u{fffe}'), false);
assert_eq!(is_private_use('\u{ffff}'), false);

// Plane 16 (PUA-B)
assert_eq!(is_noncharacter('\u{10_0000}'), false);
assert_eq!(is_noncharacter('\u{10_0001}'), false);
assert_eq!(is_noncharacter('\u{10_fffd}'), false);
assert_eq!(is_noncharacter('\u{10_fffe}'), true);
assert_eq!(is_noncharacter('\u{10_ffff}'), true);

assert_eq!(is_private_use('\u{10_0000}'), true);
assert_eq!(is_private_use('\u{10_0001}'), true);
assert_eq!(is_private_use('\u{10_fffd}'), true);
assert_eq!(is_private_use('\u{10_fffe}'), false);
assert_eq!(is_private_use('\u{10_ffff}'), false);

No runtime deps