How to deal with emojis in iOS?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to deal with emojis in iOS?



I'm trying put some emojis in a text view. Most of the emojis are ok. I used Emoji example from github. When I'm putting some emojis it's string look like (When I'm debugging),



enter image description here


-(void)textViewDidChange:(UITextView *)textView

NSString *string = self.postTxtView.text;
string = [string stringByReplacingEmojiCheatCodesWithUnicode];
NSLog(@"%@", string);
[self.postTxtView setText:string];



How may I avoid these question mark like box? How can I get a string like :woman-heart-woman:?


:woman-heart-woman:





can you show your code ? what you tried ?
– Badal Shah
Feb 18 '16 at 6:04





i edited the code
– codebot
Feb 18 '16 at 6:11





you also have to use - (NSString *)stringByReplacingEmojiCheatCodesWithUnicode; this method.
– Badal Shah
Feb 18 '16 at 6:13





I already used it!
– codebot
Feb 18 '16 at 6:17




1 Answer
1



You have to perform encoding here.



Send your string like below to server.


NSData *data1 = [vTextView.text dataUsingEncoding:NSNonLossyASCIIStringEncoding];
NSString *nameSubject = [[NSString alloc] initWithData:data1 encoding:NSUTF8StringEncoding];



Retrieve your string as emojis like below.


NSData *dataRetrive = [response[@"key"] dataUsingEncoding:NSUTF8StringEncoding];
NSString *goodValue = [[NSString alloc] initWithData:dataRetrive encoding:NSNonLossyASCIIStringEncoding];






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered