Karta.Mail.Text (Karta v1.0.0)

Small checks of text that goes into messages and their records, in one place, so that each API and module does not write its own.

column/2 is for text taken from what strangers send — a report's fields, a header — and put in a database column: it is made valid UTF-8 (lossily, as Karta.Mail.Charset.to_utf8_lossy/2 reads it), its control characters (which PostgreSQL does not store) become spaces, and it is cut to the column's length. A value that is not text, or is longer than any column, must not become a failed write that refuses a report forever.

Summary

Functions

data as a column's text, at most limit characters (default 998, the longest line RFC 5322 allows); nil for nil or empty text.

Whether text holds a control character (C0, or DEL).

Functions

column(data, limit \\ 998)

@spec column(binary() | nil, pos_integer()) :: String.t() | nil

data as a column's text, at most limit characters (default 998, the longest line RFC 5322 allows); nil for nil or empty text.

control?(text)

@spec control?(String.t()) :: boolean()

Whether text holds a control character (C0, or DEL).