PHPMailer\PHPMailer\PHPMailer::encodeString PHP Method

encodeString() public method

Returns an empty string on failure.
public encodeString ( string $str, string $encoding = 'base64' ) : string
$str string The text to encode
$encoding string The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
return string
    public function encodeString($str, $encoding = 'base64')
    {
        $encoded = '';
        switch (strtolower($encoding)) {
            case 'base64':
                $encoded = chunk_split(base64_encode($str), 76, $this->LE);
                break;
            case '7bit':
            case '8bit':
                $encoded = $this->fixEOL($str);
                // Make sure it ends with a line break
                if (substr($encoded, -strlen($this->LE)) != $this->LE) {
                    $encoded .= $this->LE;
                }
                break;
            case 'binary':
                $encoded = $str;
                break;
            case 'quoted-printable':
                $encoded = $this->encodeQP($str);
                break;
            default:
                $this->setError($this->lang('encoding') . $encoding);
                break;
        }
        return $encoded;
    }