diff options
-rw-r--r-- | MLKCharacter.h | 13 | ||||
-rw-r--r-- | MLKCharacter.m | 32 | ||||
-rw-r--r-- | MLKReadtable.m | 13 |
3 files changed, 48 insertions, 10 deletions
diff --git a/MLKCharacter.h b/MLKCharacter.h index 664803a..04049d4 100644 --- a/MLKCharacter.h +++ b/MLKCharacter.h @@ -26,7 +26,16 @@ unichar unichar; } --(MLKCharacter*) initWithUnichar:(unichar)anUnichar; +-(MLKCharacter *) initWithUnichar:(unichar)anUnichar; -+(MLKCharacter*) characterWithUnichar:(unichar)anUnichar; ++(MLKCharacter *) characterWithUnichar:(unichar)anUnichar; + +-(MLKCharacter *) uppercaseCharacter; +-(MLKCharacter *) lowercaseCharacter; + +-(unichar) uppercaseChar; +-(unichar) lowercaseChar; + ++(unichar) uppercaseCharForChar:(unichar)ch; ++(unichar) lowercaseCharForChar:(unichar)ch; @end diff --git a/MLKCharacter.m b/MLKCharacter.m index c653248..5daa22c 100644 --- a/MLKCharacter.m +++ b/MLKCharacter.m @@ -31,4 +31,36 @@ { return [[MLKCharacter alloc] initWithUnichar:anUnichar]; } + +-(MLKCharacter *) uppercaseCharacter +{ + return [MLKCharacter characterWithUnichar:[self uppercaseChar]]; +} + +-(MLKCharacter *) lowercaseCharacter +{ + return [MLKCharacter characterWithUnichar:[self lowercaseChar]]; +} + +-(unichar) uppercaseChar +{ + return [[[NSString stringWithFormat:@"%C", self->unichar] uppercaseString] + characterAtIndex:0]; +} + +-(unichar) lowercaseChar +{ + return [[[NSString stringWithFormat:@"%C", self->unichar] lowercaseString] + characterAtIndex:0]; +} + ++(unichar) uppercaseCharForChar:(unichar)ch +{ + return [[MLKCharacter characterWithUnichar:ch] uppercaseChar]; +} + ++(unichar) lowercaseCharForChar:(unichar)ch +{ + return [[MLKCharacter characterWithUnichar:ch] lowercaseChar]; +} @end diff --git a/MLKReadtable.m b/MLKReadtable.m index 59f6438..702a00b 100644 --- a/MLKReadtable.m +++ b/MLKReadtable.m @@ -17,6 +17,7 @@ */ #import "MLKReadtable.h" +#import "MLKCharacter.h" #import <Foundation/NSDictionary.h> #import <Foundation/NSValue.h> @@ -114,19 +115,15 @@ case MLKReadtableCase_PRESERVE: return ch; case MLKReadtableCase_UPCASE: - return [[[NSString stringWithFormat:@"%C", ch] uppercaseString] - characterAtIndex:0]; + return [MLKCharacter uppercaseCharForChar:ch]; case MLKReadtableCase_DOWNCASE: - return [[[NSString stringWithFormat:@"%C", ch] lowercaseString] - characterAtIndex:0]; + return [MLKCharacter lowercaseCharForChar:ch]; case MLKReadtableCase_INVERT: { unichar upCh; - upCh = [[[NSString stringWithFormat:@"%C", ch] uppercaseString] - characterAtIndex:0]; + upCh = [MLKCharacter uppercaseCharForChar:ch]; if (ch == upCh) - return [[[NSString stringWithFormat:@"%C", ch] lowercaseString] - characterAtIndex:0]; + return [MLKCharacter lowercaseCharForChar:ch]; else return upCh; } |