home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _d73a12d2c342279e3565ae896d9aac9c < prev    next >
Encoding:
Text File  |  2004-06-01  |  2.9 KB  |  106 lines

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