Expand description
This crate provides Unicode case mapping routines and iterators for conventionally UTF-8 binary strings.
Unicode case mapping or case conversion can be used to transform the characters in a string. To quote the Unicode FAQ:
Case mapping or case conversion is a process whereby strings are converted to a particular form—uppercase, lowercase, or titlecase—possibly for display to the user.
This crate is currently a work in progress. When the API is complete, Roe will support lowercase, uppercase, titlecase, and case folding iterators for conventionally UTF-8 byte slices.
Roe will implement support for full, Turkic, ASCII, and case folding transforms.
§Usage
You can convert case like:
assert_eq!(
roe::lowercase(b"Artichoke Ruby", LowercaseMode::Ascii).collect::<Vec<_>>(),
b"artichoke ruby"
);
assert_eq!(
roe::uppercase("Αύριο".as_bytes(), UppercaseMode::Full).collect::<Vec<_>>(),
"ΑΎΡΙΟ".as_bytes()
);
assert_eq!(
roe::titlecase("ffi".as_bytes(), TitlecaseMode::Full).collect::<Vec<_>>(),
"Ffi".as_bytes()
);
Roe provides fast path routines that assume the byte slice is ASCII-only.
§Crate Features
Roe is no_std
compatible with an optional dependency on the alloc
crate.
Roe has several Cargo features, all of which are enabled by default:
- std - Adds a dependency on
std
, the Rust Standard Library. This feature enablesstd::error::Error
implementations on error types in this crate. Enabling the std feature also enables the alloc feature. - alloc - Adds a dependency on
alloc
, the Rust allocation and collections library. This feature enables APIs that allocateString
orVec
.
Modules§
- unicode_
terms doc
- Roe is derived from Unicode Data Files and is subject to Unicode License v3.
Structs§
- Invalid
Case Mapping Mode - Error that indicates a failure to parse a
LowercaseMode
,UppercaseMode
, orTitlecaseMode
. - Lowercase
- An iterator that yields the lowercase equivalent of a conventionally UTF-8 byte string.
- Titlecase
- An iterator that yields the titlecase equivalent of a conventionally UTF-8 byte string.
- Uppercase
- An iterator that yields the uppercase equivalent of a conventionally UTF-8 byte string.
Enums§
- Lowercase
Mode - Options to configure the behavior of
lowercase
. - Titlecase
Mode - Options to configure the behavior of
titlecase
. - Uppercase
Mode - Options to configure the behavior of
uppercase
.
Functions§
- lowercase
- Returns an iterator that yields a copy of the bytes in the given slice with all uppercase letters replaced with their lowercase counterparts.
- make_
ascii_ lowercase - Converts the given slice to its ASCII lower case equivalent in-place.
- make_
ascii_ titlecase - Converts the given slice to its ASCII title case equivalent in-place.
- make_
ascii_ uppercase - Converts the given slice to its ASCII upper case equivalent in-place.
- titlecase
- Returns an iterator that yields a copy of the bytes in the given slice with the leading letter replaced with its titlecase counterpart and all remaining letters replaced with their lowercase counterparts.
- to_
ascii_ lowercase - Returns a vector containing a copy of the given slice where each byte is mapped to its ASCII lower case equivalent.
- to_
ascii_ titlecase - Returns a vector containing a copy of the given slice where each byte is mapped to its ASCII title case equivalent.
- to_
ascii_ uppercase - Returns a vector containing a copy of the given slice where each byte is mapped to its ASCII upper case equivalent.
- to_
titlecase - Take a
char
and return its Unicode titlecase as 3char
s. - uppercase
- Returns an iterator that yields a copy of the bytes in the given slice with all lowercase letters replaced with their uppercase counterparts.