Skip to content

String index transformer for Rust UTF-8 to JavaScript UTF-16

License

Notifications You must be signed in to change notification settings

xn-sakina/azusa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

azusa

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

Usage

use azusa::Azusa;

let text = "c😅é文";
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