The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Name

SPVM::MIME::QuotedPrint - Quoted-Printable Encoding/Decoding

Description

The MIME::QuotedPrint class of SPVM has methods for Quoted-Printable encoding/decoding.

Usage

  use MIME::QuotedPrint;
  
  my $encoded = MIME::QuotedPrint->encode_qp($decoded);
  my $decoded = MIME::QuotedPrint->decode_qp($encoded);

Class Methods

encode_qp

  static method encode_qp : string ($str : string, $eol = undef : string, $binmode = 0 : int)

Returns an Quoted-Printable encoded version of the string $str.

The second argument $eol is the line-ending sequence to use. It is optional and defaults to \n.

Every occurrence of \n is replaced with this string, and it is also used for additional "soft line breaks" to ensure that no line end up longer than 76 characters.

Pass it as \015\012 to produce data suitable for external consumption. The string \r\n produces the same result on many platforms, but not all.

The third argument $binmode will select binary mode if passed as a TRUE value. In binary mode \n will be encoded in the same way as any other non-printable character.

This ensures that a decoder will end up with exactly the same string whatever line ending sequence it uses.

An $eol of "" (the empty string) is special. In this case, no "soft line breaks" are introduced and binary mode is effectively enabled so that any \n in the original data is encoded as well.

decode_qp

  static method decode_qp : string ($str : string);

Returns the plain text version of the Quoted-Printable string $str.

The lines of the result are \n terminated, even if the $str argument contains \r\n terminated lines.

Distribution Containing This Class

SPVM::MIME::Base64

Other Modules in This Distribution

See Also

Author

Yuki Kimoto (kimoto.yuki@gmail.com)

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License