--nextPart6270562.g6kdBMs4Wu Content-Type: multipart/mixed; boundary="Boundary-01=_qFrOC6xtT4Ni1zf" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_qFrOC6xtT4Ni1zf Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi all, please have a look at the attached patch and possibly commit it. All information is available at BR#87250, I did not want to re-post it here. BTW, thanks for KDE 3.4. It is great. :-) Cheers, Mashrab. =2D-=20 Mashrab Kuvatov Ph.D student University of Bremen, IUP Home-page: www.sat.uni-bremen.de/members/mashrab PGP key: www.uni-bremen.de/~kmashrab/kmashrab.asc --Boundary-01=_qFrOC6xtT4Ni1zf Content-Type: text/x-diff; charset="utf-8"; name="kspell2-aspell-utf8.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="kspell2-aspell-utf8.patch" =2D-- kspell_aspelldict.cpp 2005-02-19 15:52:45.506305552 +0100 +++ my_kspell_aspelldict.cpp 2005-02-19 16:10:22.626598840 +0100 @@ -22,6 +22,8 @@ =20 #include =20 +#include + using namespace KSpell2; =20 ASpellDict::ASpellDict( const QString& lang ) @@ -29,6 +31,9 @@ { m_config =3D new_aspell_config(); aspell_config_replace( m_config, "lang", lang.latin1() ); + /* All communication with Aspell is done in UTF-8 */ + /* For reference, please look at BR#87250 */ + aspell_config_replace( m_config, "encoding", "utf-8" ); =20 AspellCanHaveError * possible_err =3D new_aspell_speller( m_config ); =20 @@ -47,15 +52,22 @@ =20 bool ASpellDict::check( const QString& word ) { =2D int correct =3D aspell_speller_check( m_speller, word.utf8(), word.l= ength() ); + /* ASpell is expecting length of a string in char representation */ + /* word.length() !=3D word.utf8().length() for nonlatin strings */ + int correct =3D aspell_speller_check( m_speller, word.utf8(), word.utf= 8().length() ); return correct; } =20 QStringList ASpellDict::suggest( const QString& word ) { + /* Needed for Unicode conversion */ + QTextCodec *codec =3D QTextCodec::codecForName("utf8"); + + /* ASpell is expecting length of a string in char representation */ + /* word.length() !=3D word.utf8().length() for nonlatin strings */ const AspellWordList * suggestions =3D aspell_speller_suggest( m_spell= er, word.utf8= (), =2D word.le= ngth() ); + word.utf8= ().length() ); =20 AspellStringEnumeration * elements =3D aspell_word_list_elements( sugg= estions ); =20 @@ -63,7 +75,9 @@ const char * cword; =20 while ( (cword =3D aspell_string_enumeration_next( elements )) ) { =2D qsug.append( cword ); + /* Since while creating the class ASpellDict the encoding is set */ + /* to utf-8, one has to convert output from Aspell to Unicode */ + qsug.append( codec->toUnicode( cword ) ); } =20 delete_aspell_string_enumeration( elements ); @@ -82,19 +96,25 @@ bool ASpellDict::storeReplacement( const QString& bad, const QString& good ) { + /* ASpell is expecting length of a string in char representation */ + /* word.length() !=3D word.utf8().length() for nonlatin strings */ return aspell_speller_store_replacement( m_speller, =2D bad.utf8(), bad.length(), =2D good.utf8(), good.length() = ); + bad.utf8(), bad.utf8().length= (), + good.utf8(), good.utf8().leng= th() ); } =20 bool ASpellDict::addToPersonal( const QString& word ) { + /* ASpell is expecting length of a string in char representation */ + /* word.length() !=3D word.utf8().length() for nonlatin strings */ return aspell_speller_add_to_personal( m_speller, word.utf8(), =2D word.length() ); + word.utf8().length() ); } =20 bool ASpellDict::addToSession( const QString& word ) { + /* ASpell is expecting length of a string in char representation */ + /* word.length() !=3D word.utf8().length() for nonlatin strings */ return aspell_speller_add_to_session( m_speller, word.utf8(), =2D word.length() ); + word.utf8().length() ); } --Boundary-01=_qFrOC6xtT4Ni1zf-- --nextPart6270562.g6kdBMs4Wu Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBCOrFziSmHahjHWuoRAuM7AJ0dvgUdquJfqPkiBnyui40QgXlXyACeI0wr ZPn9DiBdsoTM8P11A81524g= =n5UU -----END PGP SIGNATURE----- --nextPart6270562.g6kdBMs4Wu--