• Home
Name Date Size #Lines LOC

..--

benches/04-Jul-2025-325260

src/04-Jul-2025-2,2221,571

tests/04-Jul-2025-4028

.android-checksum.jsonD04-Jul-20252.1 KiB11

.cargo-checksum.jsonD04-Jul-20251.6 KiB11

Android.bpD04-Jul-20251.2 KiB4743

Cargo.tomlD04-Jul-20252.5 KiB130110

LICENSED04-Jul-20252.1 KiB4736

METADATAD04-Jul-2025391 1817

MODULE_LICENSE_UNICODE_3D04-Jul-20250

README.mdD04-Jul-20251.8 KiB5840

cargo_embargo.jsonD04-Jul-2025307 1616

icu4x_bionic_dep.bp.fragmentD04-Jul-202561 55

README.md

1# tinystr [![crates.io](https://img.shields.io/crates/v/tinystr)](https://crates.io/crates/tinystr)
2
3<!-- cargo-rdme start -->
4
5`tinystr` is a utility crate of the [`ICU4X`] project.
6
7It includes [`TinyAsciiStr`], a core API for representing small ASCII-only bounded length strings.
8
9It is optimized for operations on strings of size 8 or smaller. When use cases involve comparison
10and conversion of strings for lowercase/uppercase/titlecase, or checking
11numeric/alphabetic/alphanumeric, `TinyAsciiStr` is the edge performance library.
12
13## Examples
14
15```rust
16use tinystr::TinyAsciiStr;
17
18let s1: TinyAsciiStr<4> = "tEsT".parse().expect("Failed to parse.");
19
20assert_eq!(s1, "tEsT");
21assert_eq!(s1.to_ascii_uppercase(), "TEST");
22assert_eq!(s1.to_ascii_lowercase(), "test");
23assert_eq!(s1.to_ascii_titlecase(), "Test");
24assert!(s1.is_ascii_alphanumeric());
25assert!(!s1.is_ascii_numeric());
26
27let s2 = TinyAsciiStr::<8>::try_from_raw(*b"New York")
28    .expect("Failed to parse.");
29
30assert_eq!(s2, "New York");
31assert_eq!(s2.to_ascii_uppercase(), "NEW YORK");
32assert_eq!(s2.to_ascii_lowercase(), "new york");
33assert_eq!(s2.to_ascii_titlecase(), "New york");
34assert!(!s2.is_ascii_alphanumeric());
35```
36
37## Details
38
39When strings are of size 8 or smaller, the struct transforms the strings as `u32`/`u64` and uses
40bitmasking to provide basic string manipulation operations:
41* `is_ascii_numeric`
42* `is_ascii_alphabetic`
43* `is_ascii_alphanumeric`
44* `to_ascii_lowercase`
45* `to_ascii_uppercase`
46* `to_ascii_titlecase`
47* `PartialEq`
48
49`TinyAsciiStr` will fall back to `u8` character manipulation for strings of length greater than 8.
50
51[`ICU4X`]: ../icu/index.html
52
53<!-- cargo-rdme end -->
54
55## More Information
56
57For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x).
58