core::str::unicode
이 페이지의 내용
API 참조는 영어로만 있습니다. 표준 라이브러리 소스의 영어 문서 주석에서 만듭니다.
Unicode text on str: normalization
forms, full case folding, and segmentation into grapheme clusters
(user-perceived characters) and words. The tables are UCD 18.0.0,
in the runtime.
Structs
GraphemesSource
pub struct GraphemesWhat s.graphemes() returns: the grapheme clusters, in order, or
from the back with next_back / rev().
Trait implementations 3
impl Debug for Graphemesimpl Iterator for Graphemesimpl DoubleEndedIterator for Graphemes
WordBoundsSource
pub struct WordBoundsWhat s.split_word_bounds() returns: the pieces between word
boundaries, in order.
WordsSource
pub struct WordsWhat s.words() returns: the words, in order.
Enums
NormalFormSource
pub enum NormalFormA Unicode normalization form, for s.normalize(Nfc).
Canonical composition:
"e\u{301}"->"é". The form to store and compare text in.Canonical decomposition:
"é"->"e\u{301}".Compatibility composition: NFC that also replaces look-alike forms (
"fi"->"fi","①"->"1", full-width"A"->"A").Compatibility decomposition.
Implementations
impl str
Sourcepub const fn normalize(§self, form: NormalForm) -> str selfin normalization formform;selfitself, not a copy, when it already is.
Sourcepub const fn is_normalized(§self, form: NormalForm) -> bool truewhenself.normalize(form) == self, found without a copy for most text.Full Unicode case folding (
"Straße"->"strasse"), the form for caseless comparison; no locale rules. Python:s.casefold().truewhen the two are equal ignoring case and canonical equivalence: their NFD case folds (of the NFD) are equal.The extended grapheme clusters, the characters a reader sees:
"e\u{301}", a flag"🇰🇷"and an emoji ZWJ sequence"\u{1F469}\u{200D}\u{1F4BB}"are one each.The number of grapheme clusters, as
graphemes().count().Grapheme clusters
aup tob(not included), counted from 0; both clamp tographeme_count(), anda >= bgives"". O(b).
Sourcepub const fn split_word_bounds(§self) -> WordBounds The pieces between word boundaries: words, runs of spaces and each punctuation mark, all of the text in order.
The words: the
split_word_boundspieces holding a letter or a digit ("can't","3.14", each ideograph).