Display "special character" using UnicodeTag(s): Internationalization
The copyright symbol © :
String COPYRIGHT = "\u00a9";
String REGISTERED = "\u00ae";
String EURO = "\u20ac"
import java.awt.*; public class TestUnicode extends java.applet.Applet { public static final String COPYRIGHT = "\u00a9"; public static final String REGISTERED = "\u00ae"; public static final String EURO = "\u20ac"; public void init () { setLayout(new FlowLayout()); Label a = new Label(COPYRIGHT + " R\u00e9al Gagnon"); Label b = new Label(REGISTERED + " R\u00e9al's Software " + " price : 100 " + EURO); add(a); add(b); } }
Output :
A list of Unicode characters is available at the
Unicode organization Web site.
Here a quick list for accented letters :
á | \u00e0 | Á | \u00c0 |
à | \u00e1 | À | \u00c1 |
â | \u00e2 | Â | \u00c2 |
é | \u00e9 | É | \u00c9 |
è | \u00e8 | È | \u00c8 |
ê | \u00ea | Ê | \u00ca |
î | \u00ee | Î | \u00ce |
ç | \u00e7 | Ç | \u00c7 |
The Indian rupee symbol ( ₹ HTML entity : ₹
) is quite new (2010) so you need to make sure that the Font that you are using has it.
To display it from Java, you need to use Swing because AWT won't be able to display it.
import java.awt.*; import javax.swing.*; public class TestUnicode extends JApplet { public static final String RUPEE = "\u20B9"; public void init () { setLayout(new FlowLayout()); JLabel b = new JLabel("rupee : " + RUPEE); b.setFont(new Font("Arial", Font.PLAIN, 14)); add(b); } }
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com