#javascript #string #string-index #utf8-to-utf16

azusa

String index transformer for Rust utf8 to JavaScript utf16

1 stable release

1.0.1 Oct 31, 2023

#1106 in Text processing

MIT license

20KB
496 lines

azusa

Transform string index from UTF-8 in Rust to UTF-16 in JavsScript.

Usage

use azusa;

let text = "cšŸ˜…eĢę–‡";
let transformer = Azusa::new(text.into());

let utf8_range_in_rust = (1, 5);
let utf16_range_in_js = (1, 3);
assert_eq!(
    transformer.utf8_to_utf16(utf8_range_in_rust),
    utf16_range_in_js
);

// In javascript: text.slice(1, 3) === "šŸ˜…"

License

MIT

Dependencies

~1.5MB
~19K SLoC