// Check whether a given word is in the currently loaded dictionary. // This wraps enchant_dict_check. // It returns a boolean value: true if the word is in the dictionary, // false otherwise. func (d Dict) Check(word string) bool { if len(word) == 0 { return true } cWord := (*C.char)(unsafe.Pointer((*reflect.StringHeader)(unsafe.Pointer(&word)).Data)) size := C.ssize_t(uintptr(len(word))) return C.enchant_dict_check(d.dict, cWord, size) == 0 }
// Check whether a given word is in the currently loaded dictionary. // This wraps enchant_dict_check. // It returns a boolean value: true if the word is in the dictionary, // false otherwise. func (e *Enchant) Check(word string) bool { if len(word) == 0 { return true } cWord := C.CString(word) defer C.free(unsafe.Pointer(cWord)) size := uintptr(len(word)) s := (*C.ssize_t)(unsafe.Pointer(&size)) return C.enchant_dict_check(e.dict, cWord, *s) == 0 }
// DictCheck checks if a word is in the dictionary func (e *Enchant) DictCheck(word string) bool { // check if the word is in the dictionary if len(word) == 0 { // maybe make it false return true } cWord := C.CString(word) defer C.free(unsafe.Pointer(cWord)) size := uintptr(len(word)) s := (*C.ssize_t)(unsafe.Pointer(&size)) return C.enchant_dict_check(e.dict, cWord, *s) == 0 }