Reputation: 1470
I want to display asterisk symbol as superscript in my application. Is there any Unicode value for this?
Upvotes: 25
Views: 15729
Reputation: 53
In SwiftUI, you can do this for a similar result:
HStack(alignment: .firstTextBaseline, spacing: 0) {
Text("*")
Text("Example text")
}
This is because firstTextBaseLine
makes the view in the stack to be flush with the top of the larger text. In the words of the holy docs:
A guide that marks the top-most text baseline in a view.
Upvotes: 1
Reputation: 31
This helps to display asterisk in swift
let font:UIFont? = UIFont(name: "Helvetica", size:20)
let fontSuper:UIFont? = UIFont(name: "Helvetica", size:10)
let attString:NSMutableAttributedString = NSMutableAttributedString(string: "1.231*9989", attributes: [.font:font!])
attString.setAttributes([.font:fontSuper!,.baselineOffset:10], range: NSRange(location:8,length:2))
labelVarName.attributedText = attString
Upvotes: 1
Reputation: 2784
In Swift
version, simply copy this asterisk sign ⃰
and paste in your string or UILabel
text.
E.g. lblTest.text = "This is required field ⃰
This might help some other people who are seeking to put the asterisk sign in a simple string.
Upvotes: 26
Reputation: 21
I wanted a superscript asterisk to use as a footnote marker in a YouTube playlist description, since the Unicode dagger and superscript numbers looked pretty terrible. I looked through all the Unicode characters my browser could display, and the best option I came up with was U+066D, "ARABIC FIVE POINTED STAR": ٭.
Unfortunately not all fonts display it as a superscript star; for instance, the monospaced font used in the edit box I'm currently typing in displays it resting on the baseline (though the proportional font used once the answer is submitted displays it as superscript). However, the great majority of the fonts I checked on Windows do display it as superscript. Ironically, one of the few that I checked that didn't is Adobe Arabic. Strangely, most fonts display it as an asterisk-like 8- or 6-point star rather than a 5-point one.
I checked my YouTube playlist description from Safari on iOS, and unfortunately in that font, the star appears as subscript, but probably some of the fonts on iOS display it as superscript. Arabic is a right-to-left script, so you could potentially encounter issues when mixing it on a line with left-to-right script -- I was surprised for a second when my cursor went the wrong direction after typing the character on a new line in my description (it hadn't done that when typing it in the middle of a line).
Update, February 2017:
I just came across one other possibility, U+20F0, "COMBINING ASTERISK ABOVE": ⃰.
In my YouTube playlist description footnote example, however, I actually prefer the look of the Arabic Five Pointed Star. Also, the combining character works fine at the end of the word that refers to a footnote, but on the footnote definition, a couple of newlines followed by a Combining Asterisk Above at the beginning of the line undergoes whitespace-trimming upon display on YouTube, causing the newlines go away and the footnote definition to be tacked onto the end of the last paragraph (doesn't look like that in the edit box, even afterwards). I tried combining the character with a non-breaking space, but that didn't help. I have not tried viewing the Combining Asterisk Above from Safari on iOS, since that whitespace-trimming fail was a deal-killer for me.
On the plus side, Combining Asterisk Above should always be rendered as a superscript asterisk (for software supporting the 2008 Unicode 5.1.0 standard or later), whereas that's not always the case for the Arabic Five Pointed Star (which, incidentally, has been supported since 1993's Unicode 1.1.0).
Upvotes: 2
Reputation: 428
Since there is no superscript asterisk in unicode, I would go for the MODIFIER LETTER CROSS ACCENT, 0x02DF. This yields for instance A˟ or f˟.
Upvotes: 6
Reputation: 11
well, there is no unicode exist. You can do this making a small label at that particular position.
Upvotes: 0
Reputation: 25144
As per http://unicode.org/mail-arch/unicode-ml/Archives-Old/UML017/0066.html, there's no such thing as a "Superscript Asterisk" character in Unicode.
Upvotes: 16