San007 San007 - 1 year ago 165
Objective-C Question

how to show Emoji in UIlabel iOS

I have to show the textview text smily in UILabel.

In the UIlabel -

lbl.text = @"Happy to help you \U0001F431;

its showing properly.


I tried to convert
text in string and then log is -


How to encode which i can show in
, anybody please suggest me.

Answer Source
NSString *str = @"Happy to help you \U0001F431";

NSData *data = [str dataUsingEncoding:NSNonLossyASCIIStringEncoding];
NSString *valueUnicode = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

NSData *dataa = [valueUnicode dataUsingEncoding:NSUTF8StringEncoding];
NSString *valueEmoj = [[NSString alloc] initWithData:dataa encoding:NSNonLossyASCIIStringEncoding];

_lbl.text = valueEmoj;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download