Just in case somebody uses these handmade functions:
public static String superscript(String str) {
str = str.replaceAll("0", "⁰");
str = str.replaceAll("1", "¹");
str = str.replaceAll("2", "²");
str = str.replaceAll("3", "³");
str = str.replaceAll("4", "⁴");
str = str.replaceAll("5", "⁵");
str = str.replaceAll("6", "⁶");
str = str.replaceAll("7", "⁷");
str = str.replaceAll("8", "⁸");
str = str.replaceAll("9", "⁹");
return str;
}
public static String subscript(String str) {
str = str.replaceAll("0", "₀");
str = str.replaceAll("1", "₁");
str = str.replaceAll("2", "₂");
str = str.replaceAll("3", "₃");
str = str.replaceAll("4", "₄");
str = str.replaceAll("5", "₅");
str = str.replaceAll("6", "₆");
str = str.replaceAll("7", "₇");
str = str.replaceAll("8", "₈");
str = str.replaceAll("9", "₉");
return str;
}
Note, that there is a little ambiguity about ¹²³, because they are acsii symbols 251, 253 and 252 and they are also utf-symbols. I prefer to use acsii because they more probably are supported by font, but here you should decide what you actually want to use.