id)) return; $text = implode('', file("{$CFG->dataroot}/{$resource->course}/{$resource->reference}")); $remains = $text; $fragments = array(); while (preg_match('/\x00\x9F\x0F\x04.{9}(......)(.*)/s', $remains, $matches)){ $unpacked = unpack("ncode/Llength", $matches[1]); $sequencecode = $unpacked['code']; $length = $unpacked['length']; // print "length : ".$length." ; segment type : ".sprintf("%x", $sequencecode)."
"; $followup = $matches[2]; // local system encoding sequence if ($sequencecode == 0xA80F){ $aFragment = substr($followup, 0, $length); $remains = substr($followup, $length); $fragments[] = $aFragment; } // denotes unicode encoded sequence elseif ($sequencecode == 0xA00F){ $aFragment = substr($followup, 0, $length); // $aFragment = mb_convert_encoding($aFragment, 'UTF-16', 'UTF-8'); $aFragment = preg_replace('/\xA0\x00\x19\x20/s', "'", $aFragment); // some quotes $aFragment = preg_replace('/\x00/s', "", $aFragment); $remains = substr($followup, $length); $fragments[] = $aFragment; } else{ $remains = $followup; } } $indextext = implode(' ', $fragments); $indextext = preg_replace('/\x19\x20/', "'", $indextext); // some quotes $indextext = preg_replace('/\x09/', '', $indextext); // some extra chars $indextext = preg_replace('/\x0D/', "\n", $indextext); // some quotes $indextext = preg_replace('/\x0A/', "\n", $indextext); // some quotes $indextextprint = implode('
', $fragments); $logppt = fopen("C:/php5/logs/pptlog", "w"); fwrite($logppt, $indextext); fclose($logppt); if (!empty($CFG->block_search_limit_index_body)){ $indextext = shorten($text, $CFG->block_search_limit_index_body); } $indextext = mb_convert_encoding($indextext, 'UTF8', 'auto'); return $indextext; } ?>