A small Rust library to convert between the Esperanto x-system and Unicode circumflexes.
Provides a couple of utilites to convert between the Esperanto x-system (like “ehxosxangxocxiujxauxde”) and Unicode characters with circumflexes (like “eĥoŝanĝoĉiuĵaŭde”). When converting from the x-system, the X can be either a capital X or a lower-case x regardless of the case of the previous character. When converting to the X system the X will match the case of the Esperanto letter.
To use the Crate, run the following command in your project’s repository:
cargo add xsystem
The simplest way to use the Crate is with the functions
x_to_unicode
and unicode_to_x
. These convert a string slice
with one coding system to a String with the other. For example:
```rust use xsystem::{unicodetox, xtounicode};
let unichars = xtounicode("acxajxo SxANGXEMA"); asserteq!(unichars, "aĉaĵo ŜANĜEMA".tostring());
let xchars = unicodetox("terpomkaĉo estas AĈA"); asserteq!(xchars, "terpomkacxo estas ACXA".tostring()); ```
You can also use the functions x_chars
and unicode_chars
which
adapt a char iterator to perform the conversion on the fly. For example:
```rust use xsystem::{xchars, unicodechars};
let shoutyx = xchars("li estas ĉarma".chars())
.map(|c| c.touppercase())
.flatten()
.collect::
let firstconvertedchar = unicodechars("mi portas cxapelon".chars()) .position(|c| !c.isascii()); asserteq!(firstconverted_char, Some(10)); ```