Crate encode_unicode
source ·Expand description
Miscellaneous UTF-8 and UTF-16 types and methods.
Optional features:
-
#![no_std]
-mode: There are a few differences:Error
doesn’t exist, butdescription()
is made available as an inherent impl.Extend
/FromIterator
-implementations forString
/Vec<u8>
/Vec<u16>
are missing.- There is no
io
, soUtf8Iterator
andUtf8CharSplitter
doesn’t implementRead
.
This feature is enabled by setting
default-features=false
inCargo.toml
:encode_unicode = {version="0.3.4", default-features=false}
-
Integration with the ascii crate:
ConvertUtf8Char
andUtf16Char
to 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
Errors returned by various conversion methods in this crate.
Iterator types that you should rarely need to name
Structs
An unicode codepoint stored as UTF-8.
Read or iterate over the bytes of the UTF-8 representation of a codepoint.
An unicode codepoint stored as UTF-16.
Iterate over the units of the UTF-16 representation of a codepoint.
Traits
Extension trait for
char
that adds methods for converting to and from UTF-8 or UTF-16.Iterator methods that convert between
u8
s and Utf8Char
or u16
s and Utf16Char
Methods for iterating over
u8
and u16
slices as UTF-8 or UTF-16 characters.Adds
.utf8chars()
and .utf16chars()
iterator constructors to &str
.Methods for working with
u8
s as UTF-8 bytes.Methods for working with
u16
s as UTF-16 units.Functions
Converts an iterator of
Is equivalent to calling
Utf8Char
(or &Utf8Char
)
to an iterator of u8
s.Is equivalent to calling
.flat_map()
on the original iterator,
but the returned iterator is ~40% faster.Converts an iterator of
Is equivalent to calling
Utf16Char
(or &Utf16Char
)
to an iterator of u16
s.Is equivalent to calling
.flat_map()
on the original iterator,
but the returned iterator is about twice as fast.