NAME
HTTP::Promise::Stream::QuotedPrint - Stream Encoder for QuotedPrint Encoding
SYNOPSIS
use HTTP::Promise::Stream::QuotedPrint;
my $s = HTTP::Promise::Stream::QuotedPrint->new ||
die( HTTP::Promise::Stream::QuotedPrint->error, "\n" );
$s->encode( $input => $output, eol => "\n" ) ||
die( $s->error );
$s->decode( $input => $output ) || die( $s->error );
HTTP::Promise::Stream::QuotedPrint::encode_qp( $input => $output, eol => "\n" ) ||
die( $HTTP::Promise::Stream::QuotedPrint::QuotedPrintError );
HTTP::Promise::Stream::QuotedPrint::decode_qp( $input => $output, eol => "\n" ) ||
die( $HTTP::Promise::Stream::QuotedPrint::QuotedPrintError );
VERSION
v0.2.0
DESCRIPTION
This implements an encoding and decoding mechanism for quoted-printable encoding using either of the following on input and output:
filepath
-
If the parameter is neither a scalar reference nor a file handle, it will be assumed to be a file path.
file handle
-
This can be a native file handle, or an object oriented one as long as it implements the
print
orwrite
, andread
methods. Theread
method is expected to return the number of bytes read orundef
upon error. Theprint
andwrite
methods are expected to simply return true upon success andundef
upon error.Alternatively, those methods can die and those exceptions wil be caught.
scalar reference
-
This can be a simple scalar reference, or an object scalar reference.
Requires the XS module MIME::QuotedPrint for encoding and decoding.
This encodes and decodes the quoted-printable data according to rfc2045, section 6.7
CONSTRUCTOR
new
Creates a new HTTP::Promise::Stream::QuotedPrint object and returns it.
METHODS
decode
This takes 2 arguments: an input and an output. Each one can be either a file path, a file handle, or a scalar reference.
It will decode the quoted-printable encoded data and write the result into the output.
It returns true upon success and sets an error and return undef
upon error.
encode
This takes 2 arguments: an input and an output. Each one can be either a file path, a file handle, or a scalar reference.
It will encode the data into quoted-printable encoded data and write the result into the output.
If the option eol (standing for "End of line") is provided, it will be used at the end of each line of 76 characters. If eol is not provided, it will default to $/
, which usually is \n
.
It returns true upon success and sets an error and return undef
upon error.
CLASS FUNCTIONS
The following class functions are available and can also be exported, such as:
use HTTP::Promise::Stream::QuotedPrint qw( decode_qp encode_qp );
decode_qp
This takes the same 2 arguments used in "decode": an input and an output. Each one can be either a file path, a file handle, or a scalar reference.
It will decode the quoted-printable encoded data and write the result into the output.
It returns true upon success, and upon error, it will set the error in the global variable $QuotedPrintError
and return undef
my $decoded = HTTP::Promise::Stream::QuotedPrint::decode_qp( $encoded );
die( "Something went wrong: $HTTP::Promise::Stream::QuotedPrint::QuotedPrintError\n" if( !defined( $decoded ) );
print( "Decoded data is: $decoded\n" );
encode_qp
This takes the same 2 arguments used in "encode": an input and an output. Each one can be either a file path, a file handle, or a scalar reference.
It will encode the data into quoted-printable encoded data and write the result into the output.
It returns true upon success, and upon error, it will set the error in the global variable $QuotedPrintError
and return undef
my $encoded = HTTP::Promise::Stream::QuotedPrint::encode_qp( $data );
die( "Something went wrong: $HTTP::Promise::Stream::QuotedPrint::QuotedPrintError\n" if( !defined( $encoded ) );
print( "Encoded data is: $encoded\n" );
encode_qp_utf8
This takes a string, encode it into an UTF-8 string using "encode_utf8" in Encode and then encode the resulting string into quoted-printable and returns the result.
is_decoder_installed
Returns true if the module MIME::QuotedPrint is installed, false otherwise.
is_encoder_installed
Returns true if the module MIME::QuotedPrint is installed, false otherwise.
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
This encodes and decodes the quoted-printable data according to rfc2045, section 6.7
See also the Wikipedia page
HTTP::Promise, HTTP::Promise::Request, HTTP::Promise::Response, HTTP::Promise::Message, HTTP::Promise::Entity, HTTP::Promise::Headers, HTTP::Promise::Body, HTTP::Promise::Body::Form, HTTP::Promise::Body::Form::Data, HTTP::Promise::Body::Form::Field, HTTP::Promise::Status, HTTP::Promise::MIME, HTTP::Promise::Parser, HTTP::Promise::IO, HTTP::Promise::Stream, HTTP::Promise::Exception
COPYRIGHT & LICENSE
Copyright(c) 2022 DEGUEST Pte. Ltd.
All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.