std/string/quoted_printable

Standard Library documentation

Quoted-printable encoders and decoders.

Module

Name
std/string/quoted_printable
Area
Standard Library
Source
modules/std/string/quoted_printable.zzm

NAME

std/string/quoted_printable - Quoted-printable encoders and decoders.

SYNOPSIS

  from std/string/quoted_printable import encode, decode;

  let raw := to_binary( "Hello, world!\r\n" );

  let text := encode(raw);
  let bytes := decode(text);

  let binary_text := encode(raw, binary: true);
  let short_lines := encode(raw, line_length: 40, newline: "\n");

IMPLEMENTATION SUPPORT

This module is supported by all implementations of ZuzuScript.

DESCRIPTION

This module provides quoted-printable encoding and decoding helpers for RFC 2045-style byte transport. Encoding returns ASCII String text. Decoding returns a BinaryString, because quoted-printable is a byte transfer encoding rather than a Unicode text format.

The binary option controls how input line break bytes are encoded. In the default non-binary mode, CRLF, CR, and LF bytes are normalized to the configured newline string. In binary mode, CR and LF bytes are encoded as =0D and =0A.

EXPORTS

Functions

  • encode(BinaryString bytes, ... PairList options)

    Parameters: bytes is binary input data and options controls encoding. Returns: String. Encodes bytes as quoted-printable ASCII text.

  • decode(String text, ... PairList options)

    Parameters: text is quoted-printable text and options controls strictness. Returns: BinaryString. Decodes quoted-printable text into bytes.

OPTIONS

  • line_length

    Maximum encoded line length. Defaults to 76 and must be at least 4.

  • newline

    Output newline for hard line breaks and encoded soft breaks. Defaults to CRLF.

  • binary

    When true, encode CR and LF bytes as =0D and =0A. Defaults to false.

  • strict

    When true, malformed quoted-printable escape sequences throw during decoding. Non-strict decoding preserves malformed escape text literally.

COPYRIGHT AND LICENCE

std/string/quoted_printable is copyright Toby Inkster.

It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.