input chinese character in j2me

Forum for J2ME mobile games related topics including programming doubts, books and other resources for J2ME game development

input chinese character in j2me

Postby koey » Sun Jul 01, 2007 5:55 pm

Do anyone know how to display correctly the inputed chinese character in j2me? (not from a file), but simply client send the words to server. Thanks!
koey
 
Posts: 44
Joined: Fri Jan 19, 2007 5:07 pm

Postby DevelopmentTeam » Mon Jul 02, 2007 5:53 am

If you are using midlet and form then I doubt why there is a question. But when us use canvas to get input, you can read the input and show curresponding char on the screen, like how we use fonts but here you need to use drawString with uncode chars may be from a file.
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Postby koey » Sat Jul 14, 2007 3:30 pm

Still, I cannot able to do so. But unluckily, I am not able to paste the code here. Can I, instead, send that part of the code to you?
koey
 
Posts: 44
Joined: Fri Jan 19, 2007 5:07 pm

Postby DevelopmentTeam » Sun Jul 15, 2007 5:36 am

sure... you can send me the code to shankar [at] smackall [dot] com
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Postby koey » Sun Jul 15, 2007 8:41 am

Thanks a lot! I have already send the codes to you.
koey
 
Posts: 44
Joined: Fri Jan 19, 2007 5:07 pm

Postby DevelopmentTeam » Sun Jul 15, 2007 10:56 am

I will look into the code n reply back on it in the morning...
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Postby DevelopmentTeam » Mon Jul 16, 2007 7:37 am

This is how we usually implement UTF-8 text into our code. Write the text file in the desired language and save it in UTF-8 format using notpad. Now see the following code.

Code: Select all
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class SimpleUnicodeTest extends MIDlet {
Display display;
Form form = null;
StringItem msg = null;

public SimpleUnicodeTest() {
}

public void startApp() {
display = Display.getDisplay(this);
msg = new StringItem("'Hello World' in Japanese","u3053u3093u306Bu3061u306Fu4E16u754C");
form = new Form("Unicode Test");
form.append(msg);
display.setCurrent(form);
}

public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
}



To read unicode from a file

Code: Select all
public String readUnicodeFile(String filename) {
StringBuffer buffer = null;
InputStream is = null;
InputStreamReader isr = null;
try {
Class c = this.getClass();
is = c.getResourceAsStream(filename);
if (is == null)
throw new Exception("File Does Not Exist");

isr = new InputStreamReader(is,"UTF8");
buffer = new StringBuffer();
int ch;
while ((ch = isr.read()) > -1) {
buffer.append((char)ch);
}
if (isr != null)
isr.close();
} catch (Exception ex) {
System.out.println(ex);
}
return buffer.toString();
}


User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Postby DevelopmentTeam » Mon Jul 16, 2007 7:40 am

http://www4.vc-net.ne.jp/~klivo/sim/simeng.htm

you can use this tool to creat unicode files
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India


Return to J2ME Games

Who is online

Users browsing this forum: No registered users and 3 guests

cron