• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Which font are you using to display the output?
 
vidhya sagar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Hoo hoo hoo! Looks like we got a live one! Here, wave this tiny ad at it:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic