ワードファイルからテキストを読むと、次のような結果が得られます。いくつかの奇妙な文字が印刷されます。それらを削除する方法はありますか?PHPで奇妙な文字があります
I use this function to read from docx files
function readDocx() {
// Create new ZIP archive
$zip = new ZipArchive;
$dataFile = 'word/document.xml';
// Open received archive file
if (true === $zip->open($this->doc_path)) {
// If done, search for the data file in the archive
if (($index = $zip->locateName($dataFile)) !== false) {
// If found, read it to the string
$data = $zip->getFromIndex($index);
// Close archive file
$zip->close();
// Load XML from a string
// Skip errors and warnings
$xml = DOMDocument::loadXML($data, LIBXML_NOENT | LIBXML_XINCLUDE | LIBXML_NOERROR | LIBXML_NOWARNING);
// Return data without XML formatting tags
$contents = explode('\n',strip_tags($xml->saveXML()));
$text = '';
foreach($contents as $i=>$content) {
$text .= $contents[$i];
}
return $text;
}
$zip->close();
}
// In case of failure return empty string
return "";
}
この問題を解決するために何をしましたか?どのように機能していないのですか? – sarnold
修正する必要がある* encoding *の問題があるようですが、*エスケープ*とは関係ありません。詳細を教えてください。これはいつ発生するのですか?どのキャラクター*がそこにいるはずですか? – deceze
質問を詳しく教えてください。 – Lion