| 1 | # utf8_iter |
| 2 | |
| 3 | [](https://crates.io/crates/utf8_iter) |
| 4 | [](https://docs.rs/utf8_iter/) |
| 5 | |
| 6 | utf8_iter provides iteration by `char` over potentially-invalid UTF-8 `&[u8]` |
| 7 | such that UTF-8 errors are handled according to the WHATWG Encoding Standard. |
| 8 | |
| 9 | Iteration by `Result<char,Utf8CharsError>` is provided as an alternative that |
| 10 | distinguishes UTF-8 errors from U+FFFD appearing in the input. |
| 11 | |
| 12 | An implementation of `char_indices()` analogous to the same-name method on |
| 13 | `str` is also provided. |
| 14 | |
| 15 | Key parts of the code are copypaste from the UTF-8 to UTF-16 conversion code |
| 16 | in `encoding_rs`, which was optimized for speed in the case of valid input. |
| 17 | The implementation here uses the structure that was found to be fast in the |
| 18 | `encoding_rs` context but the structure hasn't been benchmarked in this |
| 19 | context. |
| 20 | |
| 21 | This is a `no_std` crate. |
| 22 | |
| 23 | ## Licensing |
| 24 | |
| 25 | TL;DR: `Apache-2.0 OR MIT` |
| 26 | |
| 27 | Please see the file named |
| 28 | [COPYRIGHT](https://github.com/hsivonen/utf8_iter/blob/master/COPYRIGHT). |
| 29 | |
| 30 | ## Documentation |
| 31 | |
| 32 | Generated [API documentation](https://docs.rs/utf8_iter/) is available |
| 33 | online. |
| 34 | |
| 35 | ## Release Notes |
| 36 | |
| 37 | ### 1.0.4 |
| 38 | |
| 39 | * Add iteration by `Result<char,Utf8CharsError>`. |
| 40 | |
| 41 | ### 1.0.3 |
| 42 | |
| 43 | * Fix an error in documentation. |
| 44 | |
| 45 | ### 1.0.2 |
| 46 | |
| 47 | * `char_indices()` implementation. |
| 48 | |
| 49 | ### 1.0.1 |
| 50 | |
| 51 | * `as_slice()` method. |
| 52 | * Implement `DoubleEndedIterator` |
| 53 | |
| 54 | ### 1.0.0 |
| 55 | |
| 56 | The initial release. |