Skip to main content

Crate mozjs_utf8_iter

Crate mozjs_utf8_iter 

Source
Expand description

Provides iteration by char over &[u8] containing potentially-invalid UTF-8 such that errors are handled according to the WHATWG Encoding Standard (i.e. the same way as in String::from_utf8_lossy).

The trait Utf8CharsEx provides the convenience method chars() on byte slices themselves instead of having to use the more verbose Utf8Chars::new(slice).

use utf8_iter::Utf8CharsEx;
let data = b"\xFF\xC2\xE2\xE2\x98\xF0\xF0\x9F\xF0\x9F\x92\xE2\x98\x83";
let from_iter: String = data.chars().collect();
let from_std = String::from_utf8_lossy(data);
assert_eq!(from_iter, from_std);

Modulesยง

cptrie ๐Ÿ”’
cptrie_indices ๐Ÿ”’
indices ๐Ÿ”’
report ๐Ÿ”’

Structsยง

ErrorReportingUtf8Chars
Iterator by Result<char,Utf8CharsError> over &[u8] that contains potentially-invalid UTF-8. There is exactly one Utf8CharsError per each error as defined by the WHATWG Encoding Standard.
Utf8CharIndices
An iterator over the chars and their positions.
Utf8CharIndicesWithTrie
An iterator over the chars and their positions.
Utf8CharIndicesWithTrieDefaultForAscii
An iterator over the chars and their positions.
Utf8Chars
Iterator by char over &[u8] that contains potentially-invalid UTF-8. See the crate documentation.
Utf8CharsError
A type for signaling UTF-8 errors.
Utf8CharsWithTrie
Iterator by char and icu_collections::codepointtrie::TrieValue over &[u8] that contains potentially-invalid UTF-8. See the crate documentation.
Utf8CharsWithTrieDefaultForAscii
Iterator by char and icu_collections::codepointtrie::TrieValue over &[u8] that contains potentially-invalid UTF-8. Uses V::default() for ASCII instead of reading from the trie. See the crate documentation.
Utf8Data ๐Ÿ”’

Staticsยง

UTF8_DATA ๐Ÿ”’

Traitsยง

Utf8CharsEx
Convenience trait that adds chars() and char_indices() methods similar to the ones on string slices to byte slices.
Utf8CharsWithTrieDefaultForAsciiEx
Convenience trait that adds chars_with_trie_default_for_ascii() and char_indices_with_trie_default_for_ascii() methods similar to the ones icu_collections::codepointtrie::CharsWithTrieEx adds to string slices to u8 slices.
Utf8CharsWithTrieEx
Convenience trait that adds chars_with_trie() and char_indices_with_trie() methods similar to the ones icu_collections::codepointtrie::CharsWithTrieEx adds to string slices to u8 slices.

Functionsยง

in_inclusive_range8 ๐Ÿ”’