PHPMailer\PHPMailer
PHPMailer::encodeString()
Encode a string in requested format. Returns an empty string on failure.
Method of the class: PHPMailer{}
No Hooks.
Return
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 6.4.1
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; }