ewts 1.0.0

Converter between EWTS (Extended Wylie Transliteration Scheme) and Tibetan Unicode symbols (lib)
Documentation
# ewts

[![Crates.io Version](https://img.shields.io/crates/v/ewts)](https://crates.io/crates/ewts)
[![docs.rs](https://img.shields.io/docsrs/ewts)](https://docs.rs/ewts/latest/ewts/)

Library to convert text between EWTS (Extended Wylie Transliteration Scheme) and Tibetan Unicode symbols, in both
directions. EWTS writes Tibetan in Latin letters: `bkra shis bde legs/` is `བཀྲ་ཤིས་བདེ་ལེགས།`.

#### [Try it online]https://tibetan.academy/en/instruments/wylie-converter/

Follows the EWTS rules of
[The Tibetan and Himalayan Library](https://www.thlib.org/reference/transliteration/#!essay=/thl/ewts/rules/);
each rule is tested in [rules_test.rs](https://github.com/emgyrz/ewts-rs/blob/master/ewts/src/rules_test.rs).
Fast: 18-120x faster than the other open-source EWTS converters
[we compared](https://github.com/emgyrz/ewts-rs/tree/master/bench) for EWTS → Unicode, 3-50x for Unicode → EWTS.
Requires Rust 1.88 or newer.

It is part of [ewts-rs](https://github.com/emgyrz/ewts-rs), a set of libs and apps that also has a CLI tool,
a wasm module and a C library.

#### Example:
```rust
let ewts_str = "oM aHhU~M` badz+ra gu ru pad+ma sid+d+hi hU~M`:";

let tib_unicode_str = ewts::ewts_to_unicode(ewts_str).unicode;

assert_eq!(tib_unicode_str, "ཨོཾ་ཨཿཧཱུྂ་བཛྲ་གུ་རུ་པདྨ་སིདྡྷི་ཧཱུྂ༔");

// And back.
assert_eq!(ewts::unicode_to_ewts("བཀྲ་ཤིས་བདེ་ལེགས།").ewts, "bkra shis bde legs/");

// Both directions also return warnings about suspicious input, with byte positions.
let result = ewts::ewts_to_unicode("kqa");
assert_eq!(result.warnings[0].kind, ewts::EwtsWarningKind::NotEwts);
assert_eq!(result.warnings[0].pos, 1);
```

## Round trip and warnings
- `unicode_to_ewts` gives EWTS that `ewts_to_unicode` converts back to the source text, unless there is a lossy
  warning (`UnicodeWarningKind::is_lossy`): with `SignOrder` the signs of a stack come back in canonical order
  (`ཀིྱ` gives `kyi`, which gives `ཀྱི`), with `NotEquivalent` a char comes back as chars that are not canonically
  equivalent to it (`ༀ` gives `oM`, which gives `ཨོཾ`).
  Precomposed chars come back as their canonically equivalent parts: `གྷ` (U+0F43) gives `g+ha`, which gives
  `ག` + `ྷ`. Non-Tibetan text is kept: ASCII other than line breaks and tabs is put in `[...]`, other text
  stays as is.
- The converter does not fix the input: if it is written incorrectly, the result has incorrect characters.
  Both directions report what looks wrong in `warnings`: see
  [`EwtsWarningKind`]https://docs.rs/ewts/latest/ewts/enum.EwtsWarningKind.html and
  [`UnicodeWarningKind`]https://docs.rs/ewts/latest/ewts/enum.UnicodeWarningKind.html.
- The one exception: typographic apostrophes `ʼ` `ʹ` `‘` `’` `ʾ`, which word processors often put instead of `'`,
  are read as `'`: `ba’i` gives `བའི`. Inside `[...]` they are kept as is. `unicode_to_ewts` puts
  them in brackets (`ka[’]`), so its result converts back exactly.

## References
- EWTS symbols [table]https://www.thlib.org/reference/transliteration/#!essay=/thl/ewts/tables/

## License
Licensed under either of [Apache License, Version 2.0](https://github.com/emgyrz/ewts-rs/blob/master/LICENSE-APACHE)
or [MIT license](https://github.com/emgyrz/ewts-rs/blob/master/LICENSE-MIT) at your option.