docs

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 Graphemes

What s.graphemes() returns: the grapheme clusters, in order, or from the back with next_back / rev().

Trait implementations 3

WordBoundsSource

pub struct WordBounds

What s.split_word_bounds() returns: the pieces between word boundaries, in order.

Trait implementations 2

WordsSource

pub struct Words

What s.words() returns: the words, in order.

Trait implementations 2

Enums

NormalFormSource

pub enum NormalForm

A 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

  • pub const fn normalize(self, form: NormalForm) -> str§

    Source

    self in normalization form form; self itself, not a copy, when it already is.

  • pub const fn is_normalized(self, form: NormalForm) -> bool§

    Source

    true when self.normalize(form) == self, found without a copy for most text.

  • pub const fn casefold(self) -> str§

    Source

    Full Unicode case folding ("Straße" -> "strasse"), the form for caseless comparison; no locale rules. Python: s.casefold().

  • pub const fn eq_ignore_case(self, other: str) -> bool§

    Source

    true when the two are equal ignoring case and canonical equivalence: their NFD case folds (of the NFD) are equal.

  • pub const fn graphemes(self) -> Graphemes§

    Source

    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.

  • pub const fn grapheme_count(self) -> usize§

    Source

    The number of grapheme clusters, as graphemes().count().

  • pub const fn grapheme_slice(self, a: usize, b: usize) -> str§

    Source

    Grapheme clusters a up to b (not included), counted from 0; both clamp to grapheme_count(), and a >= b gives "". O(b).

  • pub const fn split_word_bounds(self) -> WordBounds§

    Source

    The pieces between word boundaries: words, runs of spaces and each punctuation mark, all of the text in order.

  • pub const fn words(self) -> Words§

    Source

    The words: the split_word_bounds pieces holding a letter or a digit ("can't", "3.14", each ideograph).