PHPMailer\PHPMailer

PHPMailer::encodeString()publicWP 1.0

Encode a string in requested format. Returns an empty string on failure.

Метод класса: PHPMailer{}

Хуков нет.

Возвращает

Строку.

Использование

$PHPMailer = new PHPMailer();
$PHPMailer->encodeString( $str, $encoding );
$str(строка) (обязательный)
The text to encode
$encoding(строка)
The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
По умолчанию: self::ENCODING_BASE64

Код PHPMailer::encodeString() WP 6.5.2

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($this->lang('encoding') . $encoding);
            if ($this->exceptions) {
                throw new Exception($this->lang('encoding') . $encoding);
            }
            break;
    }

    return $encoded;
}