Reputation: 5441
I've tried to install pspell on an Ubuntu trusty distribution with the following commands:
sudo apt-get install libpspell-dev
sudo apt-get install php5-pspell
sudo apt-get install aspell-he
The process seems to have succeeded since there was no error returned during the installation process.
However, when I try this in action, I get an array of question marks(�):
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
The reason I used view is that because I thought that maybe the webpage need some charset set to it so I used HTML5 document structure to achieve that, however the result remained the same.
My HTML markup:
<!doctype html>
<html lang="he">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
סתם טקסט לבדיקה
<?php print_r($suggestions); ?>
</body>
</html>
The result returned from that:
סתם טקסט לבדיקה Array ( [0] => � [1] => � [2] => � [3] => � [4] => � [5] => � [6] => � )
I've also ran another test where I tried to do:
return pspell_check($t, 'הגדא') ? 'there is' : 'nope';
And for some reason, for any given word it returned with "nope" which means that pspell_check
returned false
Any idea how to fix this?
When trying to retrieve the length of the results:
<!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>
The result is:
1
1
1
1
1
1
1
Which means that maybe the returned results from pspell_suggest
method had problem retrieving the data from the aspell dictionary?
Upvotes: 0
Views: 121
Reputation: 5441
Since every word check returned with the same results it got me suspected that maybe the value that is being passed to the pspell_suggest
function is corrupted.
What I did was simply tell pspell
to use UTF-8:
$t = pspell_new('he', "", "", "utf-8");
This solved the problem.
Upvotes: 0
Reputation: 75645
This looks like encoding issue. You should be using UTF-8
for the HTML content (check your page <head>
and check if you set encding, BUT also you must populate your page with content encoded in the same UTF-8
. If (which can often happen) your PHP file is not UTF8 then you will have encoding mismatch and �
instead.
Upvotes: 0