diff --git a/core/spellchecker_hunspell.cpp b/core/spellchecker_hunspell.cpp index 2e8d32ed8..8de43954d 100644 --- a/core/spellchecker_hunspell.cpp +++ b/core/spellchecker_hunspell.cpp @@ -49,6 +49,8 @@ HunspellSpellChecker::HunspellSpellChecker() { wxString affpath = AegisubApp::folderName + _T("dictionaries/en_US.aff"); wxString dpath = AegisubApp::folderName + _T("dictionaries/en_US.dic"); hunspell = new Hunspell(affpath.mb_str(wxConvLocal),dpath.mb_str(wxConvLocal)); + conv = NULL; + if (hunspell) conv = new wxCSConv(wxString(hunspell->get_dic_encoding(),wxConvUTF8)); } @@ -57,13 +59,15 @@ HunspellSpellChecker::HunspellSpellChecker() { HunspellSpellChecker::~HunspellSpellChecker() { delete hunspell; hunspell = NULL; + delete conv; + conv = NULL; } ////////////////////////// // Add word to dictionary void HunspellSpellChecker::AddWord(wxString word) { - if (hunspell) hunspell->put_word(word.mb_str(wxConvUTF8)); + if (hunspell) hunspell->put_word(word.mb_str(*conv)); } @@ -71,7 +75,7 @@ void HunspellSpellChecker::AddWord(wxString word) { // Check if the word is valid bool HunspellSpellChecker::CheckWord(wxString word) { if (!hunspell) return true; - return (hunspell->spell(word.mb_str(wxConvUTF8)) == 1); + return (hunspell->spell(word.mb_str(*conv)) == 1); } @@ -85,11 +89,11 @@ wxArrayString HunspellSpellChecker::GetSuggestions(wxString word) { if (hunspell) { // Grab raw from Hunspell char **results; - int n = hunspell->suggest(&results,word.mb_str(wxConvUTF8)); + int n = hunspell->suggest(&results,word.mb_str(*conv)); // Convert each for (int i=0;i ////////////// @@ -51,6 +52,7 @@ class Hunspell; class HunspellSpellChecker : public SpellChecker { private: Hunspell *hunspell; + wxCSConv *conv; public: HunspellSpellChecker(); diff --git a/core/thesaurus_myspell.cpp b/core/thesaurus_myspell.cpp index 177421075..aac75fd65 100644 --- a/core/thesaurus_myspell.cpp +++ b/core/thesaurus_myspell.cpp @@ -47,6 +47,8 @@ MySpellThesaurus::MySpellThesaurus() { wxString idxpath = AegisubApp::folderName + _T("dictionaries/th_en_US.idx"); wxString datpath = AegisubApp::folderName + _T("dictionaries/th_en_US.dat"); mythes = new MyThes(idxpath.mb_str(wxConvLocal),datpath.mb_str(wxConvLocal)); + conv = NULL; + if (mythes) conv = new wxCSConv(wxString(mythes->get_th_encoding(),wxConvUTF8)); } @@ -55,6 +57,8 @@ MySpellThesaurus::MySpellThesaurus() { MySpellThesaurus::~MySpellThesaurus() { delete mythes; mythes = NULL; + delete conv; + conv = NULL; } @@ -66,14 +70,14 @@ void MySpellThesaurus::Lookup(wxString word,ThesaurusEntryArray &result) { // Grab raw from MyThes mentry *me; - wxCharBuffer buf = word.Lower().mb_str(wxConvUTF8); + wxCharBuffer buf = word.Lower().mb_str(*conv); int n = mythes->Lookup(buf,strlen(buf),&me); // Each entry for (int i=0;i