Using unicode in a Java program

From: William Overington (WOverington@ngo.globalnet.co.uk)
Date: Wed Jul 19 2000 - 11:08:13 EDT


I am learning to program in Java and wonder if someone could kindly point me
in the right direction as to how I can get unicode character codes into my
programs please. I have written various applets on non-unicode topics and
got them to work successfully. I am aware that Java uses unicode for all of
its characters and strings but thus far I have not been able to get any
character that cannot be typed on an ordinary keyboard into the software.

Here is what I have so far for the present program, which works.

import java.awt.*;

public class TryUnicode extends java.applet.Applet
  {
    String textstring;

    public void init()
      {
        setBackground(Color.yellow);
        textstring="The quick brown fox";
      }

    public void paint(Graphics screen)
      {
        screen.setColor(Color.blue);
        screen.drawString("" + textstring,50,200);
      }

    public void update(Graphics screen)
      {
        paint(screen);
      }

  }

Suppose that I wish to get a lowercase c circumflex character printed onto
the screen. As I understand it, this is character (decimal) 265 and
(hexadecimal) 109. From something I saw a long time ago, before I started
learning Java, I think that I need to put something like \u0109 into the
program somewhere, though whether it is \u0109 or "\u0109" in quotation
marks or whatever I do not know. Is that correct or is there some other
method please?

William Overington

19 July 2000



This archive was generated by hypermail 2.1.2 : Tue Jul 10 2001 - 17:21:06 EDT