2015-06-21 64 views
0

我試着用下面的命令的Ubuntu值得信賴的分佈安裝pspell標記():pspell回報質疑

sudo apt-get install libpspell-dev sudo apt-get install php5-pspell sudo apt-get install aspell-he

的過程似乎因爲有在返回任何錯誤已經成功安裝過程。

然而,當我嘗試這個動作,我得到問號()的數組:

pspell_config_create("he"); 
$t = pspell_new('he'); 

$suggestions = pspell_suggest($t, 'דבל'); 


return view('master', compact('suggestions')); 
// the above line can be swapped with" 
// print_r($suggestions); 
// and the result stays the same 

我使用視圖的原因是因爲我想,也許該網頁需要一些字符集設置所以我使用HTML5文檔結構來實現,但結果保持不變。

我的HTML標記:

<!doctype html> 
<html lang="he"> 
<head> 
    <meta charset="UTF-8"> 
    <title>Document</title> 
</head> 
<body> 
    סתם טקסט לבדיקה 
    <?php print_r($suggestions); ?> 
</body> 
</html> 

結果從返回:

סתם טקסט לבדיקה Array ([0] => � [1] => � [2] => � [3] => � [4] => � [5] => � [6] => �)

我也跑了另一個試驗中,在我試圖做的:

return pspell_check($t, 'הגדא') ? 'there is' : 'nope'; 

出於某種原因,對於任何給定的單詞,它都會以「nope」的形式返回,這意味着pspell_check返回false

任何想法如何解決這個問題?

編輯:

當試圖檢索結果的長度:

<!doctype html> 
<html lang="he"> 
<head> 
    <meta charset="UTF-8"> 
    <title>Document</title> 
</head> 
<body> 
@foreach($suggestions as $suggestion) 
    {{ strlen($suggestion) }} <br> 
@endforeach 
</body> 
</html> 

結果是:

1 
1 
1 
1 
1 
1 
1 

這意味着,也許從pspell_suggest方法返回結果有問題從aspell字典中檢索數據?

回答

0

由於每個字覈查與它讓我懷疑,也許正在傳遞到pspell_suggest函數值已損壞相同的結果返回。

我做了什麼簡單地告訴pspell使用UTF-8:

$t = pspell_new('he', "", "", "utf-8"); 

這解決了這個問題。

0

這看起來像編碼問題。您應該使用UTF-8作爲HTML內容(請檢查您的頁面<head>並檢查您是否設置了編碼,但是也必須使用編碼在相同UTF-8中的內容填充您的頁面。如果(通常可能發生)您的PHP文件不是UTF8那麼你將有編碼失配和代替。

+0

嘿。我試過了。看看我編輯的答案,看看我使用的HTML。答案是:'[]םArray Array Array Array [([0] => [1] => [2] => [3] => [4] => [5] => [6] = > )'。這個問題 - 不幸的是 - 依然如此 – kfirba