encodeHeader() public method

Picks shortest of Q, B, quoted-printable or none.
public encodeHeader ( string $str, string $position = 'text' ) : string
$str string
$position string
return string
Example #1
0
 /**
  * Use internal moodles own core_text to encode mimeheaders.
  * Fall back to phpmailers inbuilt functions if not 
  */
 public function encodeHeader($str, $position = 'text')
 {
     $encoded = core_text::encode_mimeheader($str, $this->CharSet);
     if ($encoded !== false) {
         $encoded = str_replace("\n", $this->LE, $encoded);
         if ($position === 'phrase') {
             return "\"{$encoded}\"";
         }
         return $encoded;
     }
     return parent::encodeHeader($str, $position);
 }
Example #2
0
 /**
  * Use internal moodles own core_text to encode mimeheaders.
  * Fall back to phpmailers inbuilt functions if not 
  */
 public function encodeHeader($str, $position = 'text')
 {
     $encoded = core_text::encode_mimeheader($str, $this->CharSet);
     if ($encoded !== false) {
         if ($position === 'phrase') {
             // Escape special symbols in each line in the encoded string, join back together and enclose in quotes.
             $chunks = preg_split("/\\n/", $encoded);
             $chunks = array_map(function ($chunk) {
                 return addcslashes($chunk, "..\\\"");
             }, $chunks);
             return '"' . join($this->LE, $chunks) . '"';
         }
         return str_replace("\n", $this->LE, $encoded);
     }
     return parent::encodeHeader($str, $position);
 }