This week's book giveaway is in the JDBC and Relational Databases forum.
We're giving away four copies of Murach's MySQL and have Joel Murach on-line!
See this thread for details.
Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to display Chinese in TextArea

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to display Chinese characters on TextArea,
but did not succeed. I tried both TextArea and JTextArea.
Please help. what shoud I do?
setFont?
setLocale?
how to change encoding?
The OS is Windows NT4.0 English version.
Thanks.
[This message has been edited by ego hu (edited May 03, 2001).]
 
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
you have to set the font to a font that supports chinese characters.
what is the key to get the charcter?
 
ego hu
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried following code:
JTextArea ta=new JTextArea();
ta.setLineWrap(true);
ta.setFont( new Font("MS Song", Font.PLAIN, 14));
ta.setLocale(new Locale("zh", "CN"));
......
ta.setText("something in Chinese @#$%&&%$#@");
What the TextArea showed is unreadable. But if I copy some
Chinese text from another editor and paste it to the TextArea, it can be displayed correctly.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to enter the text using unicode.
\u1234
You may wish to pick up "Java Internationalization" if you are going to be working with Chinese characters.
[This message has been edited by Thomas Paul (edited May 03, 2001).]
 
ego hu
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply.
In fact the contents is obtained from a file, and
I got it in String type.
Can you tell me, how to get a String in Unicode form?
Thanks.
 
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have question here:
I am working on Client Side developement project right now. Server is sending me Unicode characters like : {0x83,0x76,0x83,0x8a,0x83,0x93,0x83,0x5e,0x00}(This is Unicode characters for Japanese Language)
Now I have to convert this characters to display Japanese(Kanji) Language in Browser. How can I do it?
If anybody can explain by example. B'cos I read Internalization docs, but I can't understand properly.
Thanks,
Angela
 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have this following example :
import java.applet.Applet;
import java.awt.*;
import java.util.*;
public class langDemo extends Applet
{
public void init()
{
TextArea ta=new TextArea();
ta.setFont( new Font("Lucida Sans Unicode", Font.PLAIN,14));
ta.setLocale(new Locale("ja", "JP"));
ta.setText("{0x83,0x76,0x83,0x8a,0x83,0x93,0x83,0x5e,0x00}");
add(ta);
}
}
BUT DOESN'T DISPLAY JAPANESE LANG.!!!
Please help me out,
Thanks,
Angela
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ego hu:
Thank you for your reply.
In fact the contents is obtained from a file, and
I got it in String type.
Can you tell me, how to get a String in Unicode form?
Thanks.


Strings automatically support unicode. You must use a Reader and not an InputStream to read your file. (InputStreams do not support unicode as they do byte reads.)
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

TextArea ta=new TextArea();
BUT DOESN'T DISPLAY JAPANESE LANG.!!!
Angela[/B]


If you can, use Swing. It will make your adventure much simpler.
 
Are we home yet? Wait, did we forget the tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic