Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #16221

Re: problem with java displaying unicode, under ms-windows

From Philip Brown <phil@bolthole.com>
Newsgroups comp.lang.java.programmer
Subject Re: problem with java displaying unicode, under ms-windows
Date 2012-07-22 09:55 -0700
Organization http://groups.google.com
Message-ID <cc8d3ee0-d524-4e61-89db-eba746f3e878@googlegroups.com> (permalink)
References <096d855d-7df4-4591-a498-818ae0bb193c@googlegroups.com> <juh9cu$th3$1@dont-email.me>

Show all headers | View raw


On Sunday, July 22, 2012 9:22:52 AM UTC-7, Knute Johnson wrote:
> ....
> I copied some text from www.mainichi.co.jp into Libre Office.  I saved 
> the text as UTF-8.  I used the program below to display it.  It isn&#39;t 
> quite correct though, I get a dot before the text that wasn&#39;t on the web 
> page.  Other than that it works fine.
 

Interesting.  But it breaks the concept of "write once run anywhere", to set a platform specific font. My issue centers on how to make it work WITHOUT that hack.
As I mentioned, my program currently runs fine on MacOS, Solaris, linux, .....
I dont want any OS-specific code in my program (nor should I have to have any?!)

btw: thanks to markspace for his code, but I'm using AWT.
Kindasorta like Knute's code, but with plain Frame, not JFrame, as top.


On Sunday, July 22, 2012 9:22:52 AM UTC-7, Knute Johnson wrote:
> On 7/21/2012 10:31 PM, phil@bolthole.com wrote:
> &gt; Hi folks,
> &gt; I&#39;m hoping someone can tell me the magic to get java (6 or 7) to display unicode chars under ms-windows?
> &gt;
> &gt; This is a standalone program, not an applet:
> &gt;
> &gt; http://bolthole.com/jdrill/jdrill2_3_1.jar
> &gt;
> &gt; The program itself works; I know this, because it displays fine under macos.
> &gt; Unfortunately, the exact same jar file displays empty boxes instead of nice kanji chars, under ms-windows. Using java version 6 or 7.
> &gt;
> &gt; Looking in the font properties type files, it seems like they are referencing ms-gothic and ms-mincho fonts. which ARE present on the system.
> &gt; I see ms-gothic and ms-mincho in Control panel-&gt;fonts
> &gt; And my browser successfully displays unicode pages such as
> &gt; http://www.mainichi.co.jp/
> &gt;
> &gt; So... why isnt java displaying unicode properly???
> &gt;
> &gt; Some years ago, it was neccessary to download a special &quot;international&quot; version of java on windows, to display 16-bit-wide fonts.
> &gt; but there does not even seem to be that option any more.
> &gt; So.. what should I do?
> &gt;
> 
> I copied some text from www.mainichi.co.jp into Libre Office.  I saved 
> the text as UTF-8.  I used the program below to display it.  It isn&#39;t 
> quite correct though, I get a dot before the text that wasn&#39;t on the web 
> page.  Other than that it works fine.
> 
> import java.awt.*;
> import java.awt.event.*;
> import java.io.*;
> import java.nio.charset.*;
> import javax.swing.*;
> 
> public class test extends JPanel {
>      private char[] buffer = new char[256];
>      private int n;
> 
>      public test() {
>          setPreferredSize(new Dimension(320,240));
>          try {
>              FileInputStream fis = new FileInputStream(&quot;xxx&quot;);
>              InputStreamReader isr = new InputStreamReader(fis,&quot;UTF-8&quot;);
>              n = isr.read(buffer,0,256);
>              isr.close();
>          } catch (IOException ioe) {
>              ioe.printStackTrace();
>          }
>      }
> 
>      public void paintComponent(Graphics g) {
>          g.setFont(new Font(&quot;MS Mincho&quot;,Font.PLAIN,12));
>          g.drawChars(buffer,0,n,10,20);
>      }
> 
>      public static void main(String[] args) {
>          EventQueue.invokeLater(new Runnable() {
>              public void run() {
>                  JFrame f = new JFrame();
>                  f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
>                  f.add(new test(),BorderLayout.CENTER);
>                  f.pack();
>                  f.setVisible(true);
>              }
>          });
>      }
> }

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

problem with java displaying unicode, under ms-windows phil@bolthole.com - 2012-07-21 22:31 -0700
  Re: problem with java displaying unicode, under ms-windows Lew <noone@lewscanon.com> - 2012-07-21 23:48 -0700
    Re: problem with java displaying unicode, under ms-windows Philip Brown <phil@bolthole.com> - 2012-07-22 05:00 -0700
      Re: problem with java displaying unicode, under ms-windows Lew <noone@lewscanon.com> - 2012-07-22 13:15 -0700
  Re: problem with java displaying unicode, under ms-windows rossum <rossum48@coldmail.com> - 2012-07-22 12:53 +0100
    Re: problem with java displaying unicode, under ms-windows Philip Brown <phil@bolthole.com> - 2012-07-22 05:47 -0700
      Re: problem with java displaying unicode, under ms-windows markspace <-@.> - 2012-07-22 08:46 -0700
  Re: problem with java displaying unicode, under ms-windows Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2012-07-22 09:22 -0700
    Re: problem with java displaying unicode, under ms-windows Philip Brown <phil@bolthole.com> - 2012-07-22 09:55 -0700
      Re: problem with java displaying unicode, under ms-windows markspace <-@.> - 2012-07-22 10:10 -0700
        Re: problem with java displaying unicode, under ms-windows Philip Brown <phil@bolthole.com> - 2012-07-22 10:37 -0700
          Re: problem with java displaying unicode, under ms-windows markspace <-@.> - 2012-07-22 11:31 -0700
            Re: problem with java displaying unicode, under ms-windows Philip Brown <phil@bolthole.com> - 2012-07-22 11:40 -0700
          Re: problem with java displaying unicode, under ms-windows markspace <-@.> - 2012-07-22 11:47 -0700
          Re: problem with java displaying unicode, under ms-windows Philip Brown <phil@bolthole.com> - 2012-07-22 12:09 -0700

csiph-web