/**
  * Use internal moodles own textlib to encode mimeheaders.
  * Fall back to phpmailers inbuilt functions if not 
  */
 public function EncodeHeader($str, $position = 'text')
 {
     $encoded = textlib::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);
 }
 /**
  * Tests the static encode_mimeheader method
  * @return void
  */
 public function test_encode_mimeheader()
 {
     $str = "Žluťoučký koníček";
     $this->assertSame(textlib::encode_mimeheader($str), '=?utf-8?B?xb1sdcWlb3XEjWvDvSBrb27DrcSNZWs=?=');
 }