pub fn convert(text: &[u16], keyboard: Keyboard, mapping: Mapping) -> Vec<u16>Expand description
Convert text unit by unit. The result has the same length, and a unit the map does not
cover is copied unchanged.
use keyrill_core::mapping::{convert, Keyboard, Mapping};
let text = |s: &str| s.encode_utf16().collect::<Vec<u16>>();
assert_eq!(convert(&text("ghbdtn"), Keyboard::Apple, Mapping::EnToRu), text("привет"));
assert_eq!(convert(&text("руддщ"), Keyboard::Apple, Mapping::RuToEn), text("hello"));
// Manual mapping converts letters only and keeps punctuation.
assert_eq!(convert(&text("Ghbdtn, vbh!"), Keyboard::Apple, Mapping::Manual), text("Привет, мир!"));