5

我的 zf 项目中有以下代码:

$index = Zend_Search_Lucene::open(APPLICATION_PATH . '/cache/search_index');
        $doc = new Zend_Search_Lucene_Document();

        $title = "سلام سینا xxx sad";



        $doc->addField(Zend_Search_Lucene_Field::Text('title', $title));

        $index->addDocument($doc);
        $index->commit();

        $index->optimize();
        echo "Index contains " . $index->count() . " documents.\n\n";
        $results = $index->find('xxx');
        foreach ($results as $res) {


            var_dump($res->title);
        }

当 var_dump 执行输出时 -> string(39) "سینا جان xxx sad"

当我使用 utf_decode string(25) "س�?ا�? س�?�?ا xxx sad"

我怎样才能正确解码!:(?

我已经在这个 SOF 问题中使用了解决方案 -> zend 框架中的 lucene 编码问题

但不起作用,并添加了关于 iconv 的通知错误!

请帮助:)

4

1 回答 1

0

由此代码修复:

$index = Zend_Search_Lucene::open(APPLICATION_PATH . '/cache/search_index');
    $doc = new Zend_Search_Lucene_Document();

    $title = "سلام سینا xxx sad";



    $doc->addField(Zend_Search_Lucene_Field::Text('title', $title,"UTF8"));

    $index->addDocument($doc);
    $index->commit();

    $index->optimize();
    echo "Index contains " . $index->count() . " documents.\n\n";



    var_dump($index->getDocument(9));

    echo "Search";
     $results = $index->find('سینا');
   foreach ($results as $res) {


        var_dump($res->title);
    }

    die(1); 
于 2011-06-07T10:42:35.803 回答