Skip to main content

Module text

Module text 

Source
Expand description

Text handling for display text (draft-atwood-jmap-updates-00 §6).

  • truncate_graphemes: shorten text at an extended grapheme cluster boundary (UAX #29) within an octet limit (§6.5), for previews, notification bodies and push payloads.
  • check_display_text: the display-text profile of §6.2 (the one- and two-dimensional Modern Network Unicode rules). It is a SHOULD on content and a MAY for rejection; the crates offer the check and do not enforce it by default (gap G4 in docs/design/updates.md).

Servers SHOULD NOT normalize text they store and return (§6.3), and SHOULD give display text no meaning (§6.4): nothing here normalizes.

Structs§

DisplayTextError
Why a string breaks the display-text profile of draft-atwood-jmap-updates-00 §6.2.

Functions§

check_display_text
Check s against the display-text profile of draft-atwood-jmap-updates-00 §6.2: no control characters U+0000 to U+001F and U+007F to U+009F (except U+000A LINE FEED when multiline, so lines end with LF alone and CR is rejected), no U+2028 LINE SEPARATOR or U+2029 PARAGRAPH SEPARATOR, no noncharacters U+FFFE and U+FFFF, and no leading U+FEFF byte order mark.
truncate_graphemes
The longest prefix of s that is at most max_octets bytes of UTF-8 and ends at an extended grapheme cluster boundary (UAX #29), so no code point, combining sequence, emoji sequence or Hangul syllable is split (§6.5). Returns s unchanged when it already fits; the empty string when even the first cluster does not.
truncate_graphemes_chars
truncate_graphemes for a limit in characters (Unicode scalar values) rather than octets, as the RFC 8621 §4.1.4 Email preview (“up to 256 characters”) states it: the longest prefix of at most max_chars characters that ends at a grapheme cluster boundary.