Expand description
Miscellaneous UTF-8 and UTF-16 types and methods.
§Optional features:
-
#![no_std]-mode: There are a few differences:Errordoesn’t exist, butdescription()is made available as an inherent impl.Extend/FromIterator-implementations forString/Vec<u8>/Vec<u16>are missing.- There is no
io, soUtf8IteratorandUtf8CharSplitterdoesn’t implementRead.
This feature is enabled by setting
default-features=falseinCargo.toml:encode_unicode = {version="0.3.4", default-features=false} -
Integration with the ascii crate:
ConvertUtf8CharandUtf16Charto and from ascii::AsciiChar.
The minimum supported version of Rust is 1.15, older versions might work now but can break with a minor update.
Modules§
- error
- Errors returned by various conversion methods in this crate.
- iterator
- Iterator types that you should rarely need to name
Structs§
- Utf8
Char - An unicode codepoint stored as UTF-8.
- Utf8
Iterator - Read or iterate over the bytes of the UTF-8 representation of a codepoint.
- Utf16
Char - An unicode codepoint stored as UTF-16.
- Utf16
Iterator - Iterate over the units of the UTF-16 representation of a codepoint.
Traits§
- CharExt
- Extension trait for
charthat adds methods for converting to and from UTF-8 or UTF-16. - IterExt
- Iterator methods that convert between
u8s andUtf8Charoru16s andUtf16Char - Slice
Ext - Methods for iterating over
u8andu16slices as UTF-8 or UTF-16 characters. - StrExt
- Adds
.utf8chars()and.utf16chars()iterator constructors to&str. - U8Utf
Ext - Methods for working with
u8s as UTF-8 bytes. - U16Utf
Ext - Methods for working with
u16s as UTF-16 units.
Functions§
- iter_
bytes - Converts an iterator of
Utf8Char(or&Utf8Char) to an iterator ofu8s.
Is equivalent to calling.flat_map()on the original iterator, but the returned iterator is ~40% faster. - iter_
units - Converts an iterator of
Utf16Char(or&Utf16Char) to an iterator ofu16s.
Is equivalent to calling.flat_map()on the original iterator, but the returned iterator is about twice as fast.