3

i'v got some problems using hunspell spell checker with russian dictionaries. The problem is that my project works well with english, but if i'm going to connect russian language and trying to check spelling of my words it is always returns 0 (mean NO RESULT). Here is my code (works well for english)

char *aff = "c:\\ru_RU.aff";
char *dic = "c:\\ru_RU.dic";
Hunspell *spellObj = new Hunspell(aff,dic);
char *words = "собака"
int result = spellObj->spell(words);

result is "0". Probably the probem in encoding. I'v tried UTF-8, KOI8-R dictionaries. When using UTF-8 dictionary it can't read the "words", when using KOI8-R it's result 0.

its so bad, what i have to make it work well. p.s. last version of hunspell+vs2008 c++

Daniil
  • 31
  • 2

1 Answers1

0

New dictionaries are usually encoded to UTF-8. Same example compiled in MSYS2/mingw64 gives the correct result=1 with new UTF-8 dictionaries.

// UTF-8 file "main.cpp"
#include <iostream>
#include <hunspell.hxx>

int main()
{
char *aff = "ru_RU.aff";
char *dic = "ru_RU.dic";
Hunspell *spellObj = new Hunspell(aff,dic);
char *words = "собака";
int result = spellObj->spell(words);
std::cout << "result=" << result << std::endl;
return result;
}

Precompiled package was used. For installation, you need to enter in mingw64.exe environment pacman -Su mingw-w64-x86_64-hunspell. The content of Makefile is as follows:

PKGS=hunspell
CFLAGS=$(shell pkg-config --cflags $(PKGS)) -std=gnu++98
LIBS=$(shell pkg-config --libs $(PKGS))
all: main
%: %.cpp
    $(CXX) $(CFLAGS) -o $@ $< $(LIBS)
User
  • 11