Created
July 2, 2012 13:54
-
-
Save jilouc/3033358 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *s = @"L'asso du jour est g\\U00e9niale"; | |
NSMutableString *result = [NSMutableString string]; | |
NSScanner *scanner = [NSScanner scannerWithString:s]; | |
[scanner setCharactersToBeSkipped:nil]; | |
while (![scanner isAtEnd]) { | |
NSString *chunk; | |
[scanner scanUpToString:@"\\U" intoString:&chunk]; | |
[result appendString:chunk]; | |
if ([scanner scanString:@"\\U" intoString:nil]) { | |
NSUInteger value = 0; | |
NSRange range = NSMakeRange([scanner scanLocation], 4); | |
NSString *code = [s substringWithRange:range]; | |
[[NSScanner scannerWithString:code] scanHexInt:&value]; | |
[result appendFormat:@"%C", (unichar)value]; | |
[scanner scanString:code intoString:nil]; | |
} | |
} | |
label.text = result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment