ewts 1.0.0

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

ewts

Crates.io Version docs.rs

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

Follows the EWTS rules of The Tibetan and Himalayan Library; each rule is tested in rules_test.rs. Fast: 18-120x faster than the other open-source EWTS converters we compared for EWTS → Unicode, 3-50x for Unicode → EWTS. Requires Rust 1.88 or newer.

It is part of ewts-rs, a set of libs and apps that also has a CLI tool, a wasm module and a C library.

Example:

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 and UnicodeWarningKind.
  • 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

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.