# utf16_index_to_utf8

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

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

```rust
fn utf16_index_to_utf8(text: &str, utf16_index: usize) -> usize
```

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

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

## Availability

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