mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 21:47:00 -04:00
handle characters that have no encoding conversion in the spellchecker
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1267 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -46,11 +46,22 @@ void SpellChecker::destroyAll() {
|
|||||||
// ----------------------------------------------------------------------------- : Spell checker : use
|
// ----------------------------------------------------------------------------- : Spell checker : use
|
||||||
|
|
||||||
bool SpellChecker::spell(const String& word) {
|
bool SpellChecker::spell(const String& word) {
|
||||||
return Hunspell::spell(word.mb_str(encoding));
|
if (word.empty()) return true; // empty word is okay
|
||||||
|
#ifdef UNICODE
|
||||||
|
wxCharBuffer str = word.mb_str(encoding);
|
||||||
|
#else
|
||||||
|
wxCharBuffer str = word.mb_str(encoding);
|
||||||
|
#endif
|
||||||
|
if (*str == '\0') {
|
||||||
|
// If encoding fails we get an empty string, since the word was not empty this can never happen
|
||||||
|
// words that can't be encoded are not in the dictionary, so they are wrong.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Hunspell::spell(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
const String word_start = String(_("[({\"\'")) + LEFT_SINGLE_QUOTE + LEFT_DOUBLE_QUOTE;
|
const String word_start = String(_("[({\"\'")) + LEFT_SINGLE_QUOTE + LEFT_DOUBLE_QUOTE;
|
||||||
const String word_end = String(_("])}.,;:\"\'")) + RIGHT_SINGLE_QUOTE + RIGHT_DOUBLE_QUOTE;
|
const String word_end = String(_("])}.,;:?!\"\'")) + RIGHT_SINGLE_QUOTE + RIGHT_DOUBLE_QUOTE;
|
||||||
|
|
||||||
bool SpellChecker::spell_with_punctuation(const String& word) {
|
bool SpellChecker::spell_with_punctuation(const String& word) {
|
||||||
size_t first = word.find_first_not_of(word_start);
|
size_t first = word.find_first_not_of(word_start);
|
||||||
|
|||||||
Reference in New Issue
Block a user