The Artima Developer Community
Sponsored Link

Java Answers Forum
how do I prove java uses unicode? plz need HELP :0 /

1 reply on 1 page. Most recent reply: Mar 13, 2002 3:13 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Anders

Posts: 1
Nickname: nuclear
Registered: Mar, 2002

how do I prove java uses unicode? plz need HELP :0 / Posted: Mar 13, 2002 2:13 PM
Reply to this message Reply
Advertisement
I wounder how do I prove java uses unicode? i use jbuilder and live in LATIN~1 sweden and want to prove that java uses unicode sign and not asci/ansi... how?
can I show a chinese sign or something in someway that prove that java uses unicode? and how do calibrate my settings for that... how do i import a font if needed and where should i put it so jbuilder know it is importet... put in win98... I can show that java uses cp1252 now and that is windows asci tabell... plz need help really bad and quick.... should be so happy :>


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: how do I prove java uses unicode? plz need HELP :0 / Posted: Mar 13, 2002 3:13 PM
Reply to this message Reply
For starters, you should be running the Java 2 platform.

You can use the Font.canDisplay() method to see if the font you are using has glyphs for all the characters in your string.

Here is an example from the book Java Internationalization (all the examples from this book are available at http://www.javainternationalization.com, by the way):
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
 
public class DrawStringDemo extends JFrame {
 
  String message = "David says, \"\u05E9\u05DC\u05D5\u05DD \u05E2\u05D5\u05DC\u05DD\"";
  public DrawStringDemo() {
    super("DrawStringDemo");
  }
 
  public void paint(Graphics g) {
    Graphics2D graphics2D = (Graphics2D)g;
    GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font font = new Font("LucidaSans", Font.PLAIN, 40);
    graphics2D.setFont(font);
    graphics2D.drawString(message, 50, 75);
  }
 
  public static void main(String[] args) {
    JFrame frame = new DrawStringDemo();
    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {System.exit(0);}
    });
 
    //frame.pack();
    frame.setSize(new Dimension(500,100));
    frame.setVisible(true);
  }
}

Flat View: This topic has 1 reply on 1 page
Topic: Which Database Oracle, DB2 or SQL Server ? Previous Topic   Next Topic Topic: JSP and FORM authentication??

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use