将字符串转换为波兰语[重复]

问题描述 投票:0回答:1

这个问题在这里已有答案:

您好我已将doc文件转换为仅字符串文本。我用这个函数:Reading DOC file in php

function getRawWordText($filename) {
    if(file_exists($filename)) {
        if(($fh = fopen($filename, 'r')) !== false ) {
            $headers = fread($fh, 0xA00);
            $n1 = ( ord($headers[0x21C]) - 1 );// 1 = (ord(n)*1) ; Document has from 0 to 255 characters
            $n2 = ( ( ord($headers[0x21D]) - 8 ) * 256 );// 1 = ((ord(n)-8)*256) ; Document has from 256 to 63743 characters
            $n3 = ( ( ord($headers[0x21E]) * 256 ) * 256 );// 1 = ((ord(n)*256)*256) ; Document has from 63744 to 16775423 characters
            $n4 = ( ( ( ord($headers[0x21F]) * 256 ) * 256 ) * 256 );// 1 = (((ord(n)*256)*256)*256) ; Document has from 16775424 to 4294965504 characters
            $textLength = ($n1 + $n2 + $n3 + $n4);// Total length of text in the document
            $extracted_plaintext = fread($fh, $textLength);
            $extracted_plaintext = mb_convert_encoding($extracted_plaintext,'UTF-8');
             // if you want to see your paragraphs in a new line, do this
             // return nl2br($extracted_plaintext);
             return ($extracted_plaintext);
        } else {
            return false;
        }
    } else {
        return false;
    }  
}

这个函数返回:

毫不含糊地暗示了这个命令

它应该是:

毫不含糊地暗示了位置

我尝试将此字符串转换为抛光字母:

return strtr ($mystring, array (
            'B' => 'ł',
            '|' => 'ż',
            ));

但是我回来了:

毫不含糊地暗示了位置

我添加(像这里:PHP output showing little black diamonds with a question mark

header("Content-Type: text/html; charset=ISO-8859-1");

现在我有这个:

毫不含糊地暗示了这个立场

php string converter
1个回答
0
投票

DOC文件不是纯文本。

试试像PHPWordold CodePlex site)这样的图书馆。

nb:这个答案已经多次更新,因为PHPWord已经改变了主机和功能。

© www.soinside.com 2019 - 2024. All rights reserved.