Skip to content

Instantly share code, notes, and snippets.

@boredzo
Created January 7, 2014 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boredzo/8305377 to your computer and use it in GitHub Desktop.
Save boredzo/8305377 to your computer and use it in GitHub Desktop.
Non-working Unicode-character-in-RTF-parsing code from http://stackoverflow.com/a/20944359/30461 .
//http://stackoverflow.com/a/20944359/30461
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
NSString *unicodedString = @"{\\rtf1\\ansi\\ansicpg1252\\cocoartf1265"
@"{\\fonttbl\\f0\\fswiss\\fcharset0 Helvetica;\\f1\\fnil\\fcharset0 LucidaGrande;}"
@"{\\colortbl;\\red255\\green255\\blue255;}"
@"{\\*\\listtable{\\list\\listtemplateid1\\listhybrid{\\listlevel\\levelnfc23\\levelnfcn23\\leveljc0\\leveljcn0\\levelfollow0\\levelstartat1\\levelspace360\\levelindent0{\\*\\levelmarker \\{check\\}}{\\leveltext\\leveltemplateid1\\'01\\uc0\\u10003 ;}{\\levelnumbers;}\\fi-360\\li720\\lin720 }{\\listname ;}\\listid1}}"
@"{\\*\\listoverridetable{\\listoverride\\listid1\\listoverridecount0\\ls1}}"
@"\\paperw11900\\paperh16840\\margl1440\\margr1440\\vieww22880\\viewh16200\\viewkind0"
@"\\pard\\li720\\fi-720\\pardirnatural"
@"\\ls1\\ilvl0"
@"\\f0\\fs24 \\cf0 {\\listtext "
@"\\f1 \\uc0\\u10003 "
@"\\f0 }One\\"
@"{\\listtext "
@"\\f1 \\uc0\\u10003 "
@"\\f0 }Two\\"
@"}";
NSData *unicodedStringData = [unicodedString dataUsingEncoding:NSUTF8StringEncoding];
NSString *emojiStringValue = [[NSString alloc] initWithData:unicodedStringData encoding:NSNonLossyASCIIStringEncoding];
NSLog(@"emojiStringValue: %@", emojiStringValue);
}
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment