"Fossies" - the Fresh Open Source Software Archive

Member "MIME-Base64-3.16/lib/MIME/QuotedPrint.pm" (27 Sep 2020, 3280 Bytes) of package /linux/privat/MIME-Base64-3.16.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "QuotedPrint.pm" see the Fossies "Dox" file reference documentation.

    1 package MIME::QuotedPrint;
    2 
    3 use strict;
    4 use warnings;
    5 
    6 require Exporter;
    7 our @ISA = qw(Exporter);
    8 our @EXPORT = qw(encode_qp decode_qp);
    9 
   10 our $VERSION = '3.16';
   11 
   12 use MIME::Base64;  # will load XS version of {en,de}code_qp()
   13 
   14 *encode = \&encode_qp;
   15 *decode = \&decode_qp;
   16 
   17 1;
   18 
   19 __END__
   20 
   21 =head1 NAME
   22 
   23 MIME::QuotedPrint - Encoding and decoding of quoted-printable strings
   24 
   25 =head1 SYNOPSIS
   26 
   27  use MIME::QuotedPrint;
   28 
   29  $encoded = encode_qp($decoded);
   30  $decoded = decode_qp($encoded);
   31 
   32 =head1 DESCRIPTION
   33 
   34 This module provides functions to encode and decode strings into and from the
   35 quoted-printable encoding specified in RFC 2045 - I<MIME (Multipurpose
   36 Internet Mail Extensions)>.  The quoted-printable encoding is intended
   37 to represent data that largely consists of bytes that correspond to
   38 printable characters in the ASCII character set.  Each non-printable
   39 character (as defined by English Americans) is represented by a
   40 triplet consisting of the character "=" followed by two hexadecimal
   41 digits.
   42 
   43 The following functions are provided:
   44 
   45 =over 4
   46 
   47 =item encode_qp( $str)
   48 
   49 =item encode_qp( $str, $eol)
   50 
   51 =item encode_qp( $str, $eol, $binmode )
   52 
   53 This function returns an encoded version of the string ($str) given as
   54 argument.
   55 
   56 The second argument ($eol) is the line-ending sequence to use.  It is
   57 optional and defaults to "\n".  Every occurrence of "\n" is replaced
   58 with this string, and it is also used for additional "soft line
   59 breaks" to ensure that no line end up longer than 76 characters.  Pass
   60 it as "\015\012" to produce data suitable for external consumption.
   61 The string "\r\n" produces the same result on many platforms, but not
   62 all.
   63 
   64 The third argument ($binmode) will select binary mode if passed as a
   65 TRUE value.  In binary mode "\n" will be encoded in the same way as
   66 any other non-printable character.  This ensures that a decoder will
   67 end up with exactly the same string whatever line ending sequence it
   68 uses.  In general it is preferable to use the base64 encoding for
   69 binary data; see L<MIME::Base64>.
   70 
   71 An $eol of "" (the empty string) is special.  In this case, no "soft
   72 line breaks" are introduced and binary mode is effectively enabled so
   73 that any "\n" in the original data is encoded as well.
   74 
   75 =item decode_qp( $str )
   76 
   77 This function returns the plain text version of the string given
   78 as argument.  The lines of the result are "\n" terminated, even if
   79 the $str argument contains "\r\n" terminated lines.
   80 
   81 =back
   82 
   83 
   84 If you prefer not to import these routines into your namespace, you can
   85 call them as:
   86 
   87   use MIME::QuotedPrint ();
   88   $encoded = MIME::QuotedPrint::encode($decoded);
   89   $decoded = MIME::QuotedPrint::decode($encoded);
   90 
   91 Perl v5.8 and better allow extended Unicode characters in strings.
   92 Such strings cannot be encoded directly, as the quoted-printable
   93 encoding is only defined for single-byte characters.  The solution is
   94 to use the Encode module to select the byte encoding you want.  For
   95 example:
   96 
   97     use MIME::QuotedPrint qw(encode_qp);
   98     use Encode qw(encode);
   99 
  100     $encoded = encode_qp(encode("UTF-8", "\x{FFFF}\n"));
  101     print $encoded;
  102 
  103 =head1 COPYRIGHT
  104 
  105 Copyright 1995-1997,2002-2004 Gisle Aas.
  106 
  107 This library is free software; you can redistribute it and/or
  108 modify it under the same terms as Perl itself.
  109 
  110 =head1 SEE ALSO
  111 
  112 L<MIME::Base64>
  113 
  114 =cut