--- ./spell_pspell.inc.bak 2008-08-15 20:10:29.000000000 +0400 +++ ./spell_pspell.inc 2008-12-28 20:36:06.000000000 +0300 @@ -35,13 +35,22 @@ $words = preg_split('/[ !"#$%&()*+\\,-.\/\n:;<=>?@\[\]^_{|}]+/', $text, NULL, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE ); $plink = pspell_new(get_input_value('lang', RCUBE_INPUT_GET), null, null, 'utf-8'); $out = ''; +$oldpos=0; // previous position from singlebyte preg_split +$oldlenmb=0; // previous word lenght from multibyte strlen +$oldlensb=0; // previous word lenght from singlebyte preg_split +$realpos=0; // real position of multibyte word in singlebyte representation of text foreach ($words as $w) { $word = $w[0]; $pos = $w[1]; - $len = strlen($word); + $len = mb_strlen($word,"utf8"); // get chars count for multibyte string + $spaces = $pos - ($oldpos+$oldlensb); // get number of spaces between this and previous words + $oldpos = $pos; + $oldlensb = strlen($word); // get singlebyte chars count + $realpos = $realpos + $oldlenmb + $spaces; // real position of multibyte word in singlebyte representation of text + $oldlenmb = $len; if ($plink && !pspell_check($plink, $word)) { $suggestions = pspell_suggest($plink, $word); - $out .= ''; + $out .= ''; $out .= implode("\t", $suggestions); $out .= ''; }