how to prevent iOS from converting ascii into emoji?
Asked Answered
N

3

6

I have this simple String applied to a UILabel

labelInfo.text = "(11) ♥ 6"

this is how I need it to look like

(11) ♥ 6

this is how it looks like instead

unwanted

I really searched alot, and didn't find a way to do this..

I found ways to remove emojis, but this makes it look like this

(11) 6

if you have a hint, it will be very appreciated.

Nummary answered 19/6, 2016 at 11:57 Comment(0)
C
11

Apple has changed this in iOS 5. In most fonts, all characters that can be potentially displayed as an emoji are replaced with the colorful character from the Apple Emoji Font.

There are several solutions:

  1. Use the Unicode variant selector for non-coloured glyph: U+FE0E

labelInfo.text = "(11) \u{2665}\u{fe0e} 6"

  1. Set a font where Apple doesn't force emojis. People usually recommend Hiragino Mincho ProN.

  2. Use the graphics contexts drawing method to display the text.

Also see:

Cisterna answered 19/6, 2016 at 12:29 Comment(0)
I
2

Go to Edit->Emoji and Symbols in Xcode.Type the name of symbol you want to use(in your case heart).Copy it.Then paste it the way you want. Eg:_mylabel.text=@"♥︎"; Example

Incongruity answered 19/6, 2016 at 12:16 Comment(1)
that's a good answer, but we still don't get all symbols as some will be reserved for emojis ? or i'm mistaken ?Nummary
G
1

This worked for me:

Please make sure to use the actual ASCII symbol instead of code and append \u{0000FE0E} after it like shown below:

label.text = "♥\u{0000FE0E} Love!"

It will show up in label correctly like this:

♥ Love!

Note: Please make sure that the symbol exists in your font. In case it does not work, please try changing the font. Thank you.

Gravelly answered 26/9, 2020 at 3:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.