mag_zbc
mag_zbc

Reputation: 6992

String with Unicode literal not displaying properly on UILabel

I've got some localized strings with Unicode literals in them, like so

"some_key" = "\u{1F6C8} Some info text";

which I assign to UILabel

myLabel.text = "some_key".localized

Where localized getter looks like that

extension String {
    var localized: String {
        return NSLocalizedString(self, comment: "")
    }
}

I would expect the label would display this symbol at the beginning of my text. But instead, it just prints the symbol's code, like so

enter image description here

What's the problem?

Upvotes: -1

Views: 587

Answers (1)

muhrifqii
muhrifqii

Reputation: 19

As far as I know, you can copy that unicode character directly to the string resource. Something like "some_key" = "😀 Some text";

Edit:

But the exact unicode could return different character between iOS and android devices (happened to me). If the symbol must exactly the same across platform and it happened that the image could be added to the project asset catalog, then AttributedText with image attachment could be used.

Upvotes: -1

Related Questions