| 1 | ##---------------------------------------------------------------------------## | ||
| 2 | ## File: | ||
| 3 | ## $Id: qprint.pl,v 2.7 2005/12/20 20:27:55 ehood Exp $ | ||
| 4 | ## Authors: | ||
| 5 | ## Earl Hood mhonarc@mhonarc.org | ||
| 6 | ## Alan Barrett barrett@daisy.ee.und.ac.za | ||
| 7 | ## Description: | ||
| 8 | ## This library defines the routine to decode "quoted-printable" | ||
| 9 | ## encoded data. | ||
| 10 | ## Usage: | ||
| 11 | ## require "quoted_printable.pl"; | ||
| 12 | ## $text = "ed_printable'qprdecode($data); | ||
| 13 | ## | ||
| 14 | ##---------------------------------------------------------------------------## | ||
| 15 | ## Copyright (C) 1995-1999 Earl Hood, mhonarc@mhonarc.org | ||
| 16 | ## | ||
| 17 | ## This program is free software; you can redistribute it and/or modify | ||
| 18 | ## it under the terms of the GNU General Public License as published by | ||
| 19 | ## the Free Software Foundation; either version 2 of the License, or | ||
| 20 | ## (at your option) any later version. | ||
| 21 | ## | ||
| 22 | ## This program is distributed in the hope that it will be useful, | ||
| 23 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 24 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 25 | ## GNU General Public License for more details. | ||
| 26 | ## | ||
| 27 | ## You should have received a copy of the GNU General Public License | ||
| 28 | ## along with this program; if not, write to the Free Software | ||
| 29 | ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 30 | ##---------------------------------------------------------------------------## | ||
| 31 | |||
| 32 | package quoted_printable; | ||
| 33 | |||
| 34 | sub qprdecode { | ||
| 35 | local ($_) = shift; | ||
| 36 | |||
| 37 | s/[^\S\r\n]*(\r?\n)/$1/g; # remove trailing whitespace on each line | ||
| 38 | s/\=\r?\n//g; # remove soft linebreaks | ||
| 39 | s/=\Z//; # drop any bogus soft lb at end of text | ||
| 40 | s/=([0-9A-Fa-f]{2})/pack('H2',$1)/ge; # convert hex codes | ||
| 41 | $_; # return result | ||
| 42 | } | ||
| 43 | |||
| 44 | 1; |