Rectangle 27 1

It looks like you would need to go through each of the characters, and use stringWithFormat:@"%C" for each of the emoji characters:

// Loop through string by characters, and then do something like:
// NSString *emoji = [NSString stringWithFormat:@"%C", 16-bit Unicode character (unichar) here];
NSString *emoji = [NSString stringWithFormat:@"%C", 0xe415];
chatText.text = [chatText.text stringByAppendingString:emoji];

Thank you very much chown for your help. Im afraid it does not quite give me anything other than some Chinese characters. I have tried it on my physical iPhone and not the simulator to eliminate any possibility that the simulator might not have the emoji in it.

objective c - UILabel to display Emoji emotions rather than their unic...

objective-c
Rectangle 27 0

NSString *code = emojArray[i];
NSScanner *hexScan = [NSScanner scannerWithString:code];
unsigned int hexNum;
[hexScan scanHexInt:&hexNum];
UTF32Char inputChar = hexNum;
NSString *res = [[NSString alloc] initWithBytes:&inputChar length:4 encoding:NSUTF32LittleEndianStringEncoding];

res, when displayed in a UILabel is now an emoji.

objective c - Trying to display Emoji in a UILabel using StringWithFor...

objective-c xcode unicode emoji
Rectangle 27 0

Hi I have got one solution for that library you can find height with emoji. Please use <CoreText/CoreText.h> framework and use below code.

- (CGFloat)heightStringWithEmojis:(NSString*)str fontType:(UIFont *)uiFont ForWidth:(CGFloat)width {

    // Get text
    CFMutableAttributedStringRef attrString = CFAttributedStringCreateMutable(kCFAllocatorDefault, 0);
    CFAttributedStringReplaceString (attrString, CFRangeMake(0, 0), (CFStringRef) str );
    CFIndex stringLength = CFStringGetLength((CFStringRef) attrString);

    // Change font
    CTFontRef ctFont = CTFontCreateWithName((__bridge CFStringRef) uiFont.fontName, uiFont.pointSize, NULL);
    CFAttributedStringSetAttribute(attrString, CFRangeMake(0, stringLength), kCTFontAttributeName, ctFont);

    // Calc the size
    CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(attrString);
    CFRange fitRange;
    CGSize frameSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, 0), NULL, CGSizeMake(width, CGFLOAT_MAX), &fitRange);

    CFRelease(ctFont);
    CFRelease(framesetter);
    CFRelease(attrString);

    return frameSize.height +4;

}

objective c - iOS emoji messed up in UILabel - Stack Overflow

ios objective-c unicode encoding emoji
Rectangle 27 0

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;

Let me try, if it works. Before one was returning null.

Hi Bhavesh, You have any idea how i can convert in hex ?

objective c - how to show Emoji in UIlabel iOS - Stack Overflow

objective-c ios7 uilabel emoji
Rectangle 27 0

I have built a stringHandler class that contains the following function to overcome this issue, which pretty much solved my problem:

+ (NSString *) mapEmojiFromServer:(NSString *) inString
{
    inString = [inString stringByReplacingOccurrencesOfString:@"\\" withString:@""];
    inString = [inString stringByReplacingOccurrencesOfString:[@"ue001" lowercaseString] withString:@"\ue001"];
.
.
.

    return inString;
}

I haven't noticed a performance issue other than the IDE getting crazy when navigating and scrolling through the page that contains this 2000 lines function

Thanks a lot for your help.

objective c - UILabel to display Emoji emotions rather than their unic...

objective-c
Rectangle 27 0

I have built a stringHandler class that contains the following function to overcome this issue, which pretty much solved my problem:

+ (NSString *) mapEmojiFromServer:(NSString *) inString
{
    inString = [inString stringByReplacingOccurrencesOfString:@"\\" withString:@""];
    inString = [inString stringByReplacingOccurrencesOfString:[@"ue001" lowercaseString] withString:@"\ue001"];
.
.
.

    return inString;
}

I haven't noticed a performance issue other than the IDE getting crazy when navigating and scrolling through the page that contains this 2000 lines function

Thanks a lot for your help.

objective c - UILabel to display Emoji emotions rather than their unic...

objective-c
Rectangle 27 0

You can use Space shortcut to show the symbols panels and just insert the emoji you're looking for directly without unicode:

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

(just copy the code abode to Xcode if you browser doesn't show the emoji)

objective c - how to show Emoji in UIlabel iOS - Stack Overflow

objective-c ios7 uilabel emoji
Rectangle 27 0

It looks like you would need to go through each of the characters, and use stringWithFormat:@"%C" for each of the emoji characters:

// Loop through string by characters, and then do something like:
// NSString *emoji = [NSString stringWithFormat:@"%C", 16-bit Unicode character (unichar) here];
NSString *emoji = [NSString stringWithFormat:@"%C", 0xe415];
chatText.text = [chatText.text stringByAppendingString:emoji];

Thank you very much chown for your help. Im afraid it does not quite give me anything other than some Chinese characters. I have tried it on my physical iPhone and not the simulator to eliminate any possibility that the simulator might not have the emoji in it.

objective c - UILabel to display Emoji emotions rather than their unic...

objective-c
Rectangle 27 0

encoding:NSNonLossyASCIIStringEncoding
NSUTF8StringEncoding

Why are you converting to NSData and then back to an NSString? That makes no sense.

objective c - iOS emoji messed up in UILabel - Stack Overflow

ios objective-c unicode encoding emoji