aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes java.awt components  not able to display some non-english Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "java.awt components  not able to display some non-english " Watch "java.awt components  not able to display some non-english " New topic
Author

java.awt components not able to display some non-english

vidhya sagar
Greenhorn

Joined: Apr 05, 2007
Posts: 4
Hi All,

While we are Localizing our product we faced below problem:

java.awt components not able to display some non-english
charecters like \u2019 , \u2018 , \u2026 , \u2013 , \u8230 .

java.awt components used in our application-
1. java.awt.Choice
2.java.awt.TextField
3.java.awt.List
4.java.awt.Label

Work around:

- We tried by chaning the System Locale to chinese, then it start
diplaying properly which is not feasible solution.

NOTE:
1. Please run TestUnicode.java for how java.awt components displays
garbage values in java.awt.Choice,java.awt.TextField.

2. please run unicode.html for actual chars to be displayed.
code:

/* TestUnicode.java */

import java.awt.*;
import java.applet.*;


public class TestUnicode {

public static void main(String[] args) {

Frame f = new Frame();
Choice ch = new Choice();
f.setLayout(new FlowLayout());
ch.addItem("\u2019 = \\u2019");
ch.addItem("\u2018 = \\u2018");
ch.addItem("\u2026 = \\u2026");
ch.addItem("\u2013 = \\u2013");
ch.addItem("\u8230 = \\u8230");
TextField e = new TextField("\u2019 = \\u2019 \u2018 = \\u2018 \u2026 = \\u2026 \u2013 = \\u2013 \u8230 = \\u8230");
f.add(e);
f.add(ch);
f.pack();
f.show();
}
}


/* unicode.html */

<script

document.write("\u2019 = \\u2019 \u2018 = \\u2018 \u2026 = \\u2026
\u2013 = \\u2013 \u8230 = \\u8230"); </script>


Thanks in Advance.

Regards,
Vidhya.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
Welcome to JavaRanch.

Which font are you using to display the output?


Ping & DNS - my free Android networking tools app
vidhya sagar
Greenhorn

Joined: Apr 05, 2007
Posts: 4
1. we are not using any font as such to display.

2. Though I tried to change the font to

a) Tahoma
b) Arial Unicode MS and some more fonts

did not displayed the charecters properly.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
I'm getting the exact characters that Unicode 4.0.1 says I should get in the 20xx range, and something that looks Chinese for the 82xx character (which I think is strange, because the Unicode standard does not list any characters in the 8xxx range):



This is on OS X, which comes with a lot of fonts preinstalled.
[ April 06, 2007: Message edited by: Ulf Dittmer ]
vidhya sagar
Greenhorn

Joined: Apr 05, 2007
Posts: 4
Basing on the Locale of the host OS , it will display some charecters properly but not all charecters.

you can run the java program like

java -Duser.language=en-Duser.country=US -Duser.variant=US TestUnicode

and you may find the garbage values for those charecters.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4628658
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
I did run it on a US-English system, and as you can see, it's fine. What is a locale that produces junk characters?

I'm not sure what the character for 8230 signifies - there is no such character in the Unicode character set, so I suppose anything is possible. Are you having problems with legitimate characters as well?
vidhya sagar
Greenhorn

Joined: Apr 05, 2007
Posts: 4
From your reply, what I understood is, It will display unicode characters fine in OS (Non - English ) irrespective of locale.

Well Iam using English OS with locale as en_us where it is displaying garbage characters.

\u8230 - is a chinese character.

I have not tried with legitimate characters.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.awt components not able to display some non-english