Permalink
Browse files

Fix for Russian (and probably other languages).

Thanks go to Timur Elzhov for finding the bug and suggesting a fix.
  • Loading branch information...
1 parent 0caaee7 commit 9f125f3a67588f4db0922af3f9ebf9d2f3cad46c @eelco eelco committed Jan 19, 2011
Showing with 4 additions and 3 deletions.
  1. +4 −3 NSString+Hyphenate.m
@@ -108,7 +108,8 @@ - (NSString*)stringByHyphenatingWithLocale:(NSLocale*)locale {
if (tokenType & kCFStringTokenizerTokenHasNonLettersMask) {
[result appendString:token];
} else {
- wordLength = tokenRange.length;
+ char const* tokenChars = [[token lowercaseString] UTF8String];
+ wordLength = strlen(tokenChars);
// This is the buffer size the algorithm needs.
hyphens = (char*)malloc(wordLength + 5); // +5, see hypen.h
rep = NULL; // Will be allocated by the algorithm
@@ -117,8 +118,8 @@ - (NSString*)stringByHyphenatingWithLocale:(NSLocale*)locale {
// rep, pos and cut are not currently used, but the simpler
// hyphenation function is deprecated.
- hnj_hyphen_hyphenate2(dict, [[token lowercaseString] UTF8String],
- wordLength, hyphens, NULL, &rep, &pos, &cut);
+ hnj_hyphen_hyphenate2(dict, tokenChars, wordLength, hyphens,
+ NULL, &rep, &pos, &cut);
NSUInteger loc = 0;
NSUInteger len = 0;

0 comments on commit 9f125f3

Please sign in to comment.