realhydroper-utf16 1.1.0

Work with UTF-16 in Rust
Documentation
  • Coverage
  • 43.48%
    10 out of 23 items documented0 out of 17 items with examples
  • Size
  • Source code size: 38.21 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.06 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • matheusds365

UTF-16

Work with UTF-16 in Rust.

Differences to other crates

  • utf16string - realhydroper-utf16 uses code units as u16 instead of octets for indexing strings, as opposed to utf16string.

Converting offsets between UTF-8 and UTF-16

Use the utils submodule for converting between offset encodings:

use realhydroper_utf16::{Utf16String, utils::*};

let utf8string = "a\u{10FFFF}b\u{10000}";
let utf16string = Utf16String::from(utf8string);

// (start: usize, end: usize)
assert_eq!(two_utf16_offsets_as_utf8_offsets(utf8string, &utf16string, 3, 4), (5, 6));
assert_eq!(two_utf8_offsets_as_utf16_offsets(&utf16string, utf8string, 5, 6), (3, 4));