Retreive an instance of the encoder as a singleton.
New instances are never ever needed since it's monostatic.
static
Message_Encoder
instance
()
Break a string apart at every occurence of <add@ress> and return an array This method does NOT remove any characters like a preg_split() would do.
Elements matching an address start with "a" followed by the numeric index
array
addressChunk
(string $input)
-
string
$input: The input string to separate
Return the base64 encoded version of the string
string
base64Encode
(string $data, [int $chunk = 76], int $init_chunk, [boolean $headers = false], [string $le = "\r\n"])
-
string
$data: The input string to encode
-
int
$chunk: The maximum length of each line of output (inc CRLF)
-
int
$init_chunk: The maximum length of the first line in the output (for headers)
-
boolean
$headers: Whether email addresses between < and > chars should be preserved or not
-
string
$le: The line ending
Return the base64 encoded version of a file
-
Swift_File
$file: The file input stream
-
int
$chunk: Max line length
-
string
$le: The line ending
Encode a string as 7bit ascii
string
encode7Bit
(string $data, [int $chunk = 76], [string $le = "\r\n"])
-
string
$data: Input data to encode
-
int
$chunk: Max line length
-
string
$le: The line ending
Return a 7bit string from a file
-
Swift_File
$file: The file stream to read from
-
int
$chunk: The max line length
-
string
$le: The line ending
Strip out any characters which are not in the ASCII 7bit printable range
string
encode7BitPrintable
(string $data)
-
string
$data: The string to clean
Return the 8bit encoded form of a string (unchanged there-abouts)
string
encode8Bit
(string $data, [int $chunk = 76], [string $le = "\r\n"])
-
string
$data: Input data to encode
-
int
$chunk: Maximum line length
-
string
$le: The line ending
Return a 8bit string from a file
-
Swift_File
$file: The file stream to read from
-
int
$chunk: Max line length (including CRLF)
-
string
$le: The line ending
Fixes line endings to be whatever is specified by the user
SMTP requires the CRLF be used, but using sendmail in -t mode uses LF This method also escapes dots on a start of line to avoid injection
string
fixLE
(string $data, $le)
-
string
$data: The data to fix
-
$le
void
getHcf
( $value, $factor)
Keeps lines longer than 76 characters trimmed down to size
This currently does not convert other string encodings into 7bit
string
header7BitEncode
(string $data, [int $chunk = 76], int $init_chunk, [string $le = "\r\n"])
-
string
$data: The data to make safe for headers (defaults to RFC 2822 standards)
-
int
$chunk: maximum length of lines returned
-
int
$init_chunk: The maximum length of the first line
-
string
$le: The Line ending
If the characters fall exclusively in the 7bit ascii range, return true
boolean
is7BitAscii
(string $data)
-
string
$data: Input to check
This function checks for 7bit *printable* characters
which excludes \r \n \t etc and so, is safe for use in mail headers Actual permitted chars [\ !"#\$%&'\(\)\*\+,-\.\/0123456789:;<=>\?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]\^_`abcdefghijklmnopqrstuvwxyz{\|}~] Ranges \x00-\x1F are printer control sequences \x7F is the ascii delete character
boolean
is7BitPrintable
(string $data)
-
string
$data: Data to check against
Check that a string does not contain any evil characters for headers.
boolean
isHeaderSafe
(string $data)
-
string
$data: The string to check
Detect if a string contains multi-byte non-ascii chars that fall in the UTF-8 ranges
boolean
isUTF8
(string $data)
-
string
$data: Data to detect UTF-8 sequences in
Return the quoted printable version of the input string
string
QPEncode
(string $data, [int $chunk = 76], int $init_chunk, [boolean $headers = false], [string $le = "\r\n"])
-
string
$data: The input string to encode
-
int
$chunk: The maximum length of each line of output (inc CRLF)
-
int
$init_chunk: The maximum length of the first line in the output (for headers)
-
boolean
$headers: Whether email addresses between < and > chars should be preserved or not
-
string
$le: The line ending
Return a file as a quoted printable encoded string
-
Swift_File
$file: The file to encode
-
int
$chunk: Max line length
-
string
$le: The line ending
Break a string apart at every occurence of <xxxyyy> and return an array This method does NOT remove any characters like a preg_split() would do.
Elements matching a quoted string start with "a" followed by the numeric index
array
quoteChunk
(string $input)
-
string
$input: The input string to separate
Return the base64 encoded version of a string with no breaks
string
rawBase64Encode
(The $string)
-
The
$string: input string to encode
Return the QP encoded version of a string with no breaks
string
rawQPEncode
(string $string, [boolean $bin = false])
-
string
$string: The input to encode
-
boolean
$bin: True if the data we're encoding is binary
Encode a string for RFC 2047 compatability (url-encode)
string
rfc2047Encode
(string $str, [string $charset = "iso-8859-1"], [string $language = "en-us"], [int $chunk = 76], [int $le = "\r\n"], string 5)
-
string
5: The line ending
-
string
$str: The input for encoding
-
string
$charset: The charset used
-
string
$language: The language used
-
int
$chunk: The maximum line length
-
int
$le: The maximum length of the first line