I have a problem with umlauts in a NSString converting to const char*.
This method parses a textfile of words (line by line), saves the words as strings in NSArray *results. Then convert to const char tmpConstChars. This const char saves, for example, an 'ä' like '√§'. How to convert from NSString to const char * - I Thought this is correct.
- (void)inputWordsByFile:(NSString *)path
{
NSError *error = [[NSError alloc] init];
NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
NSArray *results = [content componentsSeparatedByString:@"\n"];
NSMutableArray *words = [[NSMutableArray alloc] initWithArray:results];
[words removeLastObject];
for(int i=0; i<[words count]; i++){
const char *tmpConstChars = [[words objectAtIndex:i] UTF8String];
[self addWordToTree:tmpConstChars];
}
}
alloc/inittheerrorobject.NSLog(@"%s",tmpConstChars+2);will give me "§hlen" for "zählen", it should give me "hlen".