https://github.com/artichoke/roe
🍣 Unicode case converters
https://github.com/artichoke/roe
artichoke case case-mapping lowercase no-std rust rust-crate titlecase unicode unicode-case-mapping uppercase utf-8
Last synced: 6 months ago
JSON representation
🍣 Unicode case converters
- Host: GitHub
- URL: https://github.com/artichoke/roe
- Owner: artichoke
- License: mit
- Created: 2021-01-17T14:18:39.000Z (over 4 years ago)
- Default Branch: trunk
- Last Pushed: 2025-04-01T00:30:28.000Z (7 months ago)
- Last Synced: 2025-04-01T01:29:31.225Z (7 months ago)
- Topics: artichoke, case, case-mapping, lowercase, no-std, rust, rust-crate, titlecase, unicode, unicode-case-mapping, uppercase, utf-8
- Language: Rust
- Homepage: https://crates.io/crates/roe
- Size: 3.23 MB
- Stars: 9
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# roe
[](https://github.com/artichoke/roe/actions)
[](https://codecov.artichokeruby.org/roe/index.html)
[](https://discord.gg/QCe2tp2)
[](https://twitter.com/artichokeruby)
[](https://crates.io/crates/roe)
[](https://docs.rs/roe)
[](https://artichoke.github.io/roe/roe/)Implements [Unicode case mapping] for [conventionally UTF-8 binary strings].
[unicode case mapping]: https://unicode.org/faq/casemap_charprop.html#casemap
[conventionally utf-8 binary strings]:
https://docs.rs/bstr/1.*/bstr/#when-should-i-use-byte-strings> 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.`roe` can convert conventionally UTF-8 binary strings to capitalized, lowercase,
and uppercase forms. This crate is used to implement [`String#capitalize`],
[`Symbol#capitalize`], [`String#downcase`], [`Symbol#downcase`],
[`String#upcase`], and [`Symbol#upcase`] in [Artichoke Ruby].[`string#capitalize`]:
https://ruby-doc.org/core-3.1.2/String.html#method-i-capitalize
[`symbol#capitalize`]:
https://ruby-doc.org/core-3.1.2/Symbol.html#method-i-capitalize
[`string#downcase`]:
https://ruby-doc.org/core-3.1.2/String.html#method-i-downcase
[`symbol#downcase`]:
https://ruby-doc.org/core-3.1.2/Symbol.html#method-i-downcase
[`string#upcase`]: https://ruby-doc.org/core-3.1.2/String.html#method-i-upcase
[`symbol#upcase`]: https://ruby-doc.org/core-3.1.2/Symbol.html#method-i-upcase
[artichoke ruby]: https://github.com/artichoke/artichokeThis crate depends on [`bstr`].
[`bstr`]: https://crates.io/crates/bstr
## Implementation
Roe generates conversion tables from Unicode Data Files. Roe implements case
mapping as defined in the [Unicode standard][casemap] (see [`PropList.txt`],
[`SpecialCasing.txt`], [`UnicodeData.txt`]).[casemap]: https://unicode.org/faq/casemap_charprop.html#casemap
[`proplist.txt`]: generated/ucd/PropList.txt
[`specialcasing.txt`]: generated/ucd/SpecialCasing.txt
[`unicodedata.txt`]: generated/ucd/UnicodeData.txt## Status
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
Add this to your `Cargo.toml`:
```toml
[dependencies]
roe = "0.0.7"
```Then convert case like:
```rust
use roe::{LowercaseMode, UppercaseMode, TitlecaseMode};assert_eq!(
roe::lowercase(b"Artichoke Ruby", LowercaseMode::Ascii).collect::>(),
b"artichoke ruby"
);
assert_eq!(
roe::uppercase("Αύριο".as_bytes(), UppercaseMode::Full).collect::>(),
"ΑΎΡΙΟ".as_bytes()
);
assert_eq!(
roe::titlecase("ffi".as_bytes(), TitlecaseMode::Full).collect::>(),
"Ffi".as_bytes()
);
```## 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 enables [`std::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 allocate [`String`] or
[`Vec`].[`alloc`]: https://doc.rust-lang.org/alloc/index.html
[`std`]: https://doc.rust-lang.org/std/index.html
[`std::error::error`]: https://doc.rust-lang.org/std/error/trait.Error.html
[`string`]: https://doc.rust-lang.org/stable/alloc/string/struct.String.html
[`vec`]: https://doc.rust-lang.org/stable/alloc/vec/struct.Vec.html## Unicode Version
Roe implements Unicode case mapping with the Unicode 16.0.0 case mapping
ruleset.Each new release of Unicode may bring updates to the Data Files which are the
source for the case mappings in this crate. Updates to the case mapping rules
will be accompanied with a minor version bump.## License
`roe` is licensed under the [MIT License](LICENSE) (c) Ryan Lopopolo.
`roe` includes Unicode Data Files which are subject to the [Unicode Terms of
Use] and [Unicode License v3](LICENSE-UNICODE) (c) 1991-2024 Unicode, Inc.[unicode terms of use]: https://www.unicode.org/copyright.html