-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Russian not fixed completely #1
Comments
Here's the patch to make hyphenation work correctly for Russian and get rid of NSRangeException: --- NSString+Hyphenate.m 2011-01-19 17:17:51.000000000 +0300
+++ /Users/xfire/Documents/works/dvp/iphone/rbc/Classes/NSString+Hyphenate/NSString+Hyphenate.m 2011-08-13 19:12:55.000000000 +0400
@@ -11,7 +11,7 @@
@implementation NSString (Hyphenate)
-- (NSString*)stringByHyphenatingWithLocale:(NSLocale*)locale {
+- (NSString *) stringByHyphenatingWithLocale:(NSLocale*)locale {
static HyphenDict* dict = NULL;
static NSString* localeIdentifier = nil;
static NSBundle* bundle = nil;
@@ -123,7 +123,7 @@
NSUInteger loc = 0;
NSUInteger len = 0;
- for (i = 0; i < wordLength; i++) {
+ for (i = 0; i < tokenRange.length; i++) {
if (hyphens[i] & 1) {
len = i - loc + 1;
[result appendString:
@@ -134,7 +134,7 @@
}
if (loc < wordLength) {
[result appendString:
- [token substringWithRange:NSMakeRange(loc, wordLength - loc)]];
+ [token substringWithRange:NSMakeRange(loc, tokenRange.length - loc)]];
}
// Clean up Enjoy! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NSString+Hyphenate.m
...
111: char const* tokenChars = [[token lowercaseString] UTF8String];
112: wordLength = strlen(tokenChars)]; // <-- Doubles length on multybyte words!
...
NSMakeRange(loc, wordLength - loc) below crashes due to
'*** -[NSCFString substringWithRange:]: Range or index out of bounds'.
Correcly: wordLength = [token length];
The text was updated successfully, but these errors were encountered: