# utf8_index_to_utf16

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/media/text_formatting/function-utf8_index_to_utf16/

**function** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
fn utf8_index_to_utf16(text: &str, utf8_index: usize) -> usize
```

Converts a UTF-8 byte offset into `text` to the UTF-16 code unit index of
the same position. An offset inside a character maps to the start of that
character; an offset past the end maps to the UTF-16 length.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/text_formatting/text_index.rs#L23)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
