Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to encode emoji while sending to server (Ruby on Rails)?

While I am sending the emoji to server "\ud83d\ude0e" (emoji unicode) in the given format, the server could not understand the code and while sending push notification from server to device, the notification is not coming.

I have used :

NSData *data = [self.activeTextField.text dataUsingEncoding:NSNonLossyASCIIStringEncoding];
NSString *goodValue = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

to encode the message(emoji) while sending and used:

NSData *data = [strReceivedMsg dataUsingEncoding:NSUTF8StringEncoding];
NSString *goodValue = [[NSString alloc] initWithData:data encoding:NSNonLossyASCIIStringEncoding];

while receiving the messages.

Please suggest how to resolve this issue

Thanks

like image 470
Sailendra Avatar asked May 31 '16 12:05

Sailendra


1 Answers

NSString *string = @"This is \u00B7";

Instead of \u00B7 add your unicode value. Its working solution.

like image 87
Pushkraj P. Lanjekar Avatar answered Oct 17 '22 18:10

Pushkraj P. Lanjekar