How to create class that will display chinese language.

Hi guys,

I am new with J2ME and I am task to create a class that will convert static text menus from English to Chinese or vice-versa.

I would like to create an option for language settings乧then if I choose Chinese all the static menus and submenus will be displayed in Chinese Font. I am using the J2ME wireless toolkit v2.2乧Your help would be much appreciated乧Thanks in advance

Back-岪

CANCEL-庢徚

OK-旤岲

HELP-暻彆

and etc

...I tried the example below but only square is seen on the screen.

import javax.microedition.lcdui.*;

import javax.microedition.midlet.*;

public class SimpleUnicodeTest extends MIDlet {

Display display;

Form form = null;

StringItem msg = null;

public SimpleUnicodeTest() {

msg = new StringItem("'Hello World' in Simplified Chinese","\u4F60\u597D\u4E16\u754C");

form = new Form("Unicode Test");

form.append(msg);

}

public void startApp() {

display = Display.getDisplay(this);

display.setCurrent(form);

}

public void pauseApp() {}

public void destroyApp(boolean unconditional) {}

}

Thanks,

psyeu

[1192 byte] By [psyeua] at [2007-11-27 5:45:44]
# 1
May be your emulator/phone does not support chinese font.Or codes are incorrect.BTW you cat create java files in UTF-16 and write in chinese directly.(You need appropriate editor) String s="Somewhat in chinese: 慖潰岅尵 "
learnphysicsa at 2007-7-12 15:27:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

Hi learnphysics

Thanks for the advice...I am currently using Eclipse 3.2 with eclipseme but when I try to run the file

with this line of code that includes chinese character

msg = new StringItem("'Hello World' in Simplified Chinese","你好世界");

it is displayed in editor but when I try to save or run it.

A dialog box appears

Save could not be completed.

Reason:

Some characters cannot be mapped using "Cp1252" character encoding.

Either change the encoding or remove the characters which are not supported by the "Cp1252"

character encoding.

Do you have any idea/suggestion on how to resolve it...

Do I have to install new font like Arial Unicode MS?

regards,

psyeu

psyeua at 2007-7-12 15:27:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
Try to use notepad for editing .Menu - Save - Encoding-UTF
learnphysicsa at 2007-7-12 15:27:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4
*deleted*Message was edited by: supareno
suparenoa at 2007-7-12 15:27:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5
I tested one game with chinese language in WTK.I also have squares. Try to find how to change font in WTK emulator in docs.Motorola emulators for motorola devices has direct support for chinese. (but crashes often on loading games)
learnphysicsa at 2007-7-12 15:27:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 6
Thanks to all of you....I can now display chinese fonts in Sun's WTK emulatorby adding fonts to windows system that supports unicode like bitstream cyberbit...After that editing the .properties file of the phone that will be used...psyeu.
psyeua at 2007-7-12 15:27:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 7

Mate,

I fixed this issue like this. Go to

1. Windows Menu --> Preferences --> General (expand it) --> Workspace (click on it).

2. Look for a box "Text File Encoding". Default will be "Cp1252".

3. Change radio to select other and select "UTF-8" from combo box.

P.S: I am using eclipse v3.2.0

cheers folks.

Message was edited by:

ceaserme

ceasermea at 2007-7-12 15:27:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...