#unicode-characters #utf-16 #unicode #utf-8

no-std encode_unicode

UTF-8 and UTF-16 character types, iterators and related methods for char, u8 and u16

13 releases (1 stable)

1.0.0 Aug 7, 2022
0.3.6 Aug 23, 2019
0.3.5 Oct 23, 2018
0.3.2 Aug 8, 2018
0.1.3 Apr 7, 2016

#135 in Encoding

Download history 473410/week @ 2024-07-19 466093/week @ 2024-07-26 451426/week @ 2024-08-02 498382/week @ 2024-08-09 520013/week @ 2024-08-16 511260/week @ 2024-08-23 482374/week @ 2024-08-30 539574/week @ 2024-09-06 471924/week @ 2024-09-13 562637/week @ 2024-09-20 535671/week @ 2024-09-27 598290/week @ 2024-10-04 567468/week @ 2024-10-11 606069/week @ 2024-10-18 623808/week @ 2024-10-25 570900/week @ 2024-11-01

2,482,640 downloads per month
Used in 5,235 crates (20 directly)

Apache-2.0 OR MIT

155KB
2K SLoC

encode_unicode

UTF-8 and UTF-16 character types, iterators and related methods for char, u8 and u16.

crates.io page License: Apache-2 or MIT Documentation on docs.rs CI build status

Features

Minimum supported Rust version

The minimum supported Rust version for 1.0.* releases is 1.56.
Later 1.y.0 releases might require newer Rust versions, but the three most recent stable releases at the time of publishing will always be supported. For example this means that if the current stable Rust version is 1.66 when encode_unicode 1.1.0 is released, then encode_unicode 1.1.* will not require a newer Rust version than 1.63.

Optional features

  • #![no_std]-mode: There are a few differences:
    • Error doesn't exist, but description() is made available as an inherent impl.
    • Extend/FromIterator-implementations for String/Vec<u8>/Vec<u16> are missing.
    • There is no io, so Utf8Iterator and Utf8CharSplitter doesn't implement Read. This feature is enabled by setting default-features=false in Cargo.toml: encode_unicode = {version="0.3.4", default-features=false}.
  • Integration with the ascii crate: Convert Utf8Char and Utf16Char to and from ascii::AsciiChar.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Developing

do.sh can be used to check all feature combinations, test everything, show output from benchmarks in case setup fails, run fuzz tests for a while and lint everything (except fuzz tests).
It assumes rustup is installed and that cargo +release works.
(It is named the way it is to autocomplete fully from the first character after ./.)

History

The original purpose of this crate was to provide standins for the then unstable encode_utf8() and encode_utf16() methods on char.
The standins were removed in version 0.3 when Rust 1.15 stabilized the encode_ methods, but the other stuff I added, such as iterators like those encode_utf{8,16}() returned for a while, might still be of use.

Dependencies