How to add Superscript string in Localization file in iOS

I have localizable English and French files. I want display Registered symbols as a part of word i.e "MyApp®". English part of localization file shows this symbol correct in iOS APP UI. Same needs to display for French version i.e "MyApp ".

I also tried using unicode like MyApp\u{1D39}\u{1D30}. This gets worked in Swift playground but if I try it through Localization file it doesn't work below iOS 12( it shows ? insread of . On iOS 12 its working fine.


iOS version : 11.4 : I need to make changes in localization file only and not to use NSAttributed string every where in code. If anyone came across same problem, and found solution please post.


Below things I tried :

"MyApp®" = "MyApp\u{1D39}\u{1D30}" // Localization file

print(String(describing: "MyApp\u{1D39}\u{1D30}" // swift playground print(String(describing: " ")) // swift playground


"MyApp®" = "MyApp\u{1D39}\u{1D30}" // Localization file "MyApp®" = "MyApp ")) // Localization file- on UI it displaspace comes b/w ᴹ and ᴰ

print(String(describing: "MyApp\u{1D39}\u{1D30}" // swift playground print(String(describing: " ")) // swift playground


"MyApp®" = "MyApp\u{1D39}\u{1D30}" // Localization file

On iOS app UI component should render MyApp® as MyApp

Replies

The localization file is not a Swift source code file, so you can't use Swift literal syntax like \u{ … }. It's just a text file.


That means, out of your various efforts, this one should be the correct form:


"MyApp®" = "MyAppᴹᴰ";


with a semicolon after the translation string. (I'm not sure why your post is showing "))" after each string.)


It's not clear why you're seeing a space between the M and the D. You should start by writing a line of test code to get the localized string:


let string = NSLocalizedString("MyApp®", comment: "")


and then examine the string character by character (or Unicode scalar by Unicode scalar). It may be that there is no space character there, or there is a non-printing character (but not a space), or there is really a space, but you can't solve this until you know which.

Thanks QuinceyMorris for quick reply.

I have just updated the description. The seems to be working fine on iOS 12 with superscript but below iOS 12 it shows "?".