/**
  * byte oriented line folding fix
  *
  * remove any line-endings that may include spaces or tabs
  * and convert all line endings (iCal default '\r\n'),
  * takes care of '\r\n', '\r' and '\n' and mixed '\r\n'+'\r', '\r\n'+'\n'
  *
  * @author Kjell-Inge Gustafsson, kigkonsult <*****@*****.**>
  * @since 2.18.16 - 2014-04-04
  * @param string $text
  * @param string $nl
  * @return string
  */
 public static function convEolChar(&$text, $nl)
 {
     /* fix dummy line separator */
     if (empty(iCalUtilityFunctions::$baseDelim)) {
         iCalUtilityFunctions::$baseDelim = substr(microtime(), 2, 4);
         $base = 'aAbB!cCdD"eEfF#gGhHiIjJ%kKlL&mMnN/oOpP(rRsS)tTuU=vVxX?uUvV*wWzZ-1234_5678|90';
         $len = strlen($base) - 1;
         for ($p = 0; $p < 6; $p++) {
             iCalUtilityFunctions::$baseDelim .= $base[mt_rand(0, $len)];
         }
     }
     /* fix eol chars */
     $text = str_replace(array("\r\n", "\n\r", "\n", "\r"), iCalUtilityFunctions::$baseDelim, $text);
     /* fix empty lines */
     $text = str_replace(iCalUtilityFunctions::$baseDelim . iCalUtilityFunctions::$baseDelim, iCalUtilityFunctions::$baseDelim . str_pad('', 75) . iCalUtilityFunctions::$baseDelim, $text);
     /* fix line folding */
     $text = str_replace(iCalUtilityFunctions::$baseDelim, $nl, $text);
     $text = str_replace(array($nl . ' ', $nl . "\t"), '', $text);
     /* split in component/property lines */
     $text = explode($nl, $text);
     return $text;
 }