void CreateSpeller(char * affPath, char * dictPath, HWND hMain, COLORREF color){ char *enc; m_hMain = hMain; if(m_hh){ Hunspell_destroy(m_hh); m_hh = NULL; } m_hh = Hunspell_create(affPath, dictPath); enc = _strdup(Hunspell_get_dic_encoding(m_hh)); enc = _normalizeCodePage(enc); m_CodePage = SendMessage(hMain, SPM_GETCODEPAGE, 0, (LPARAM)enc); free(enc); if(m_Pen){ DeleteObject(m_Pen); m_Pen = NULL; } m_Pen = CreatePen(PS_SOLID, 1, color); strcpy(m_CustPath, affPath); PathRemoveFileSpec(m_CustPath); strcat(m_CustPath, "\\"); _loadCustomDictionary(); }
static int HunSpell_init(HunSpell * self, PyObject *args, PyObject *kwds) { PyObject *dpath; PyObject *apath; #if PY_VERSION_HEX < 0x03010000 if (!PyArg_ParseTuple(args, "etet", Py_FileSystemDefaultEncoding, &dpath, Py_FileSystemDefaultEncoding, &apath)) #else if (!PyArg_ParseTuple(args, "O&O&", PyUnicode_FSConverter, &dpath, PyUnicode_FSConverter, &apath)) #endif return 1; self->handle = Hunspell_create(PyBytes_AsString(apath), PyBytes_AsString(dpath)); self->encoding = Hunspell_get_dic_encoding(self->handle); Py_DECREF(dpath); Py_DECREF(apath); return 0; }
static PyObject * HunSpell_get_dic_encoding(HunSpell * self, PyObject *args) { return Py_BuildValue("s", Hunspell_get_dic_encoding(self->handle)); }