Sunday, May 19, 2013

NSString precomposedStringWithCanonicalMapping example ios


[NSString precomposedStringWithCanonicalMapping]

Returns a string made by normalizing the receiver’s contents using Form C.
- (NSString *)precomposedStringWithCanonicalMapping
Return Value
A string made by normalizing the receiver’s contents using the Unicode Normalization Form C.
Example of [NSString precomposedStringWithCanonicalMapping]
BOOL flag = [[lang precomposedStringWithCanonicalMapping] isEqualToString:
                    [currentLang precomposedStringWithCanonicalMapping]];
Example of [NSString precomposedStringWithCanonicalMapping]
static void 
precomposedOutput( char *fn )
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    char buffer[BUFFERSIZE] ;
    char *outbuf;
    FILE *fd = stdin ;
    if (fn) {
        fd = fopen(fn,"r");
    }
    while ( fgets(buffer, sizeof(buffer),fd ) ) {
        NSString *str = [[NSString alloc] initWithUTF8String:buffer];
        NSString *str_precomp = [[NSString alloc ] initWithString:[str precomposedStringWithCanonicalMapping]] ;
        outbuf = (char *)[str_precomp UTF8String] ;
        [str release ] ; 
        [str_precomp release ] ;
        fputs(outbuf,stdout) ;
    }
    [pool drain];
}
Example of [NSString precomposedStringWithCanonicalMapping]
NSLog(@"localPath Length:%d",[[localPath precomposedStringWithCanonicalMapping] length]);