San007 San007 - 3 months ago 28
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.

In
UITextView
-

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

%F0%9F%99%88%F0%9F%99%89%F0%9F%99%8A


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

Answer
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;