PHPMailer\PHPMailer
PHPMailer::encodeString
Encode a string in requested format. Returns an empty string on failure.
Method of the class: PHPMailer{}
No Hooks.
Returns
String.
Usage
$PHPMailer = new PHPMailer(); $PHPMailer->encodeString( $str, $encoding );
- $str(string) (required)
- The text to encode.
- $encoding(string)
- The encoding to use; one of
'base64','7bit','8bit','binary','quoted-printable'.
Default:self::ENCODING_BASE64
PHPMailer::encodeString() PHPMailer::encodeString code WP 7.0
public function encodeString($str, $encoding = self::ENCODING_BASE64)
{
$encoded = '';
switch (strtolower($encoding)) {
case static::ENCODING_BASE64:
$encoded = chunk_split(
base64_encode($str),
static::STD_LINE_LENGTH,
static::$LE
);
break;
case static::ENCODING_7BIT:
case static::ENCODING_8BIT:
$encoded = static::normalizeBreaks($str);
//Make sure it ends with a line break
if (substr($encoded, -(strlen(static::$LE))) !== static::$LE) {
$encoded .= static::$LE;
}
break;
case static::ENCODING_BINARY:
$encoded = $str;
break;
case static::ENCODING_QUOTED_PRINTABLE:
$encoded = $this->encodeQP($str);
break;
default:
$this->setError(self::lang('encoding') . $encoding);
if ($this->exceptions) {
throw new Exception(self::lang('encoding') . $encoding);
}
break;
}
return $encoded;
}