+ NSString * word_ = toString(word);
+ NSString * lang_ = toString(lang);
+ SpellCheckResult result = SPELL_CHECK_FAILED;
+ int start = 0;
+ int length = [word_ length];
+
+ [speller->misspelled release];
+ speller->misspelled = nil;
+
+ while (result == SPELL_CHECK_FAILED && start < length) {
+ NSRange match = [speller->checker
+ checkSpellingOfString:word_
+ startingAt:start
+ language:lang_
+ wrap:(BOOL)NO
+ inSpellDocumentWithTag:speller->doctag
+ wordCount:NULL];
+
+ result = match.length == 0 ? SPELL_CHECK_OK : SPELL_CHECK_FAILED;
+ if (result == SPELL_CHECK_OK) {
+ if ([NSSpellChecker instancesRespondToSelector:@selector(hasLearnedWord:)]) {
+ if ([speller->checker hasLearnedWord:word_])
+ result = SPELL_CHECK_LEARNED;
+ }
+ } else {