Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put math symbols (e.g. R^n) into Java String?

I would like to display the R^n math symbol in a javafx Label. How could I do this? I found the unicode number for a real number - U+211x (https://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode#Letterlike_Symbols_block), but inserting \u+211x into the Label string like below gives an 'invalid unicode' error

Label dim_label = new Label("n ( \u+212x ^n):");
like image 776
Cheetaiean Avatar asked Mar 03 '23 13:03

Cheetaiean


1 Answers

The correct symbol is \u211D, the x in Wikipedia is just a placeholder and the + should not go to the string.

The exponent n is SUPERSCRIPT LATIN SMALL LETTER N and can be represented with \u207F.

So all in all:

Label dim_label = new Label("n ( \u211D\u207F):");

Live demo:.

n ( ℝⁿ):
like image 98
ruohola Avatar answered Mar 05 '23 15:03

ruohola