Question

I have stored all uni-codes(emoji characters) in plist supported by iphone. When i write directly as

- (IBAction)sendButtonSelected:(id)sender {
NSMutableArray *emoticonsArray = [[NSMutableArray alloc]initWithObjects:@"\ue415",nil];
NSString *imageNameToPass = [NSString stringWithFormat:@"%@",[emoticonsArray objectAtIndex:0]];
NSLog(@"imageNameToPass1...%@",imageNameToPass);
messageTextView.text =imageNameToPass;
 }

it show emoji in textview but as soon as i fetch from plist

NSString *plistPath1 = [[NSBundle mainBundle] pathForResource:@"unicodes" ofType:@"plist"];
NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:plistPath1];
activeArray= [dictionary objectForKey:categoryString];

NSLog(@"activeArray...%@",activeArray);

emoticonsArrayForHomeEmoji = [[NSMutableArray alloc]initWithCapacity:[activeArray count]];
for(int i=0; i<[activeArray count]; i++)
{
    id objects = (id)[activeArray objectAtIndex:i];
    [emoticonsArrayForHomeEmoji insertObject:objects atIndex:i];
}
NSString *imageNameToPass = [NSString stringWithFormat:@"%@",[emoticonsArrayForHomeEmoji 
objectAtIndex:0]];
NSLog(@"imageNameToPass1...%@",imageNameToPass);
messageTextView.text =imageNameToPass;

then it shows unicode as text \ue415 in text view instead of emoji.

What i am doing wrong?. Please help me out!

Was it helpful?

Solution

The \uxxxx notation is only interpreted by the compiler (as the source code is usually in ASCII or MacRoman or whatever but not often UTF8)

Plist files uses the characters directly, and are encoded in UTF8. So you should insert the emoji character itself into the plist directly, instead of using the \uxxxx notation, as the Plist data will be read as-is.

Lion and Mountain Lion Keyboard palettes contains emoji characters directly, so that should not be difficult to insert the characters when editing the PLIST anyway.

OTHER TIPS

Wel said by @AliSoftware, the Plist data will be read as-it is, so you can add the emojis to your plist by following this steps:

1) Go to your top bar, and click on Edit.

2) Now select Special Characters

3) Now drag and drop emoji to plist.

For more details I am adding snap shots. take a look at it.Step No. 1Step No. 2Step No. 3

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top