# umsc
`umsc` is a Rust library for converting Uyghur text between multiple writing systems.
It is a port of the original Python `UgMultiScriptConverter` and supports conversions between:
- `UAS` - Uyghur Arabic Script
- `ULS` - Uyghur Latin Script
- `UYS` - Uyghur Yengi Script
- `CTS` - Common Turkic Script
- `UCS` - Uyghur Cyrillic Script
- `XJUS` - Xinjiang University English Case Sensitive
- `UZLS` - Uzbek Latin Script
- `IPA` - IPA output from `CTS`
## Installation
Add the crate to your project:
```bash
cargo add umsc
```
Or add it manually to `Cargo.toml`:
```toml
[dependencies]
umsc = "1.0.0"
```
## Usage
### Convert with the top-level function
```rust
use umsc::{convert, Script};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let arabic = "ئاپ";
let latin = convert(arabic, Script::Uas, Script::Uls)?;
assert_eq!(latin, "ap");
Ok(())
}
```
### Reuse a converter instance
```rust
use umsc::{Script, UgMultiScriptConverter};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let converter = UgMultiScriptConverter::new(Script::Cts, Script::Uas);
let text = converter.convert("ap")?;
assert_eq!(text, "ئاپ");
Ok(())
}
```
### Parse scripts from strings
```rust
use std::str::FromStr;
use umsc::{convert, Script};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let source = Script::from_str("uas")?;
let target = Script::from_str("ucs")?;
let text = convert("ئاپ", source, target)?;
assert_eq!(text, "ап");
Ok(())
}
```
## Supported conversions
The library only exposes the conversion pairs implemented by the original Python logic. For example:
- `UAS -> CTS`, `ULS`, `UCS`, `UYS`, `UZLS`
- `ULS -> CTS`, `UAS`, `UCS`, `UYS`
- `UYS -> CTS`, `UAS`, `ULS`, `UCS`
- `UCS -> CTS`, `UAS`, `ULS`, `UYS`
- `XJUS -> CTS`, `UAS`
- `UZLS -> CTS`
- `CTS -> UAS`, `ULS`, `UYS`, `UCS`, `UZLS`, `XJUS`, `IPA`
Unsupported pairs return an error.
## Notes
- Conversion behavior follows the original Python script as closely as practical.
- Some transliteration paths are table-driven and order-sensitive by design.
- This crate is a library only; it does not currently provide a CLI binary.