关于J2ME中的汉字显示问题(高手指教)

XHGosling 2001-09-27 02:49:20
我的j2me手机模拟器是在SUN的网站下载的,在程式中使用J2ME Wireless SDK中的 javax.microedition.lcdui.*(用户界面包)中的class,例如TextField可以显示正常的中文标题,但由
javax.microedition.io.*中的HttpConnection由网络上取得的字节数组byte[]后却无法通过java.lang.String中的String(byte[],String encode)方式转化为GB2312或GBK编码,模拟器控制台显示
结果为没有这种编码,我实验了其他的编码,发现只有ISO8859_1能通过运行,不知UI包是如何在手机中显示简体中文汉字的。
...全文
210 15 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
hgj1229 2001-12-07
  • 打赏
  • 举报
回复
我已经解决了这个问题,告诉你:
先要用GB2312:
byte[] adreco=names.getBytes("GB2312");
然后取的时候要用GB2312:
String str=new String(adreco,"GB2312");
hgj1229 2001-12-07
  • 打赏
  • 举报
回复
我已经解决了这个问题,告诉你:
先要用GB2312:
byte[] adreco=names.getBytes("GB2312");
然后取的时候要用GB2312:
String str=new String(adreco,"GB2312");
hgj1229 2001-12-07
  • 打赏
  • 举报
回复
我也是刚遇到此问题,你试了没有,请告诉我好吗?
XHGosling 2001-10-14
  • 打赏
  • 举报
回复
I have solved my problem, thanks for all your reply
rockswang 2001-10-02
  • 打赏
  • 举报
回复
是不是用UTF8的?
raindays 2001-09-29
  • 打赏
  • 举报
回复
没什么问题,直接按字节数组方式转换就行了
wzy25 2001-09-28
  • 打赏
  • 举报
回复
用j2mewtk1.0.3吧,中文完全没有问题,
如果是从httpconnection取出来的,编码转换一下就可以了

XHGosling 2001-09-28
  • 打赏
  • 举报
回复
constructor HelloWorld() need add public key word,
or your environment of project setting is error,
you can see the demo setting and set it.
XHGosling 2001-09-28
  • 打赏
  • 举报
回复
多谢各位关注,已到SUN的网站问过了,目前无解。
to fengYang,sorry,时间紧,稍后给你答复。
tiger_lei 2001-09-28
  • 打赏
  • 举报
回复
你这个就是最简单的MIDlet。
1。你的wtk是什么版本的
2。是否按照步骤来写的:
1。生成新的project.
2. 将你的源文件拷贝到j2mewtk目录/apps/你的project/src下。
3. 修改setting,将MIDlets一栏中Class改为你的Class的全名(com.mot.***)
4. build run package。
3。什么时候出现null exception:java.lang.nullpointer 的,手机上显示什么?出现启动画面了吗? (select one to lanch ,下面是你的MIDlet名(在setting中设的))
fengyang 2001-09-27
  • 打赏
  • 举报
回复
我还是不行
能否写个最简单的HelloWorld程序让我运行运行,看看行不行?
tiger_lei 2001-09-27
  • 打赏
  • 举报
回复
我运行了没有问题呀,不过要把constructor改为public才行。
rockswang 2001-09-27
  • 打赏
  • 举报
回复
关注。
to fengyang(社会主义好啊社会主义好!就是好啊就是好) 
catch住exception, 用printStackTrace找到出错的地方先。
fengyang 2001-09-27
  • 打赏
  • 举报
回复
XHGosling:
我刚入此道,现遇到点问题,望解答:
我都快要急疯了!!我的j2me程序,用j2me wireless toolkit 可以built通过,但是run时,总是出错:null exception:java.lang.nullpointer Exception.我用的都是一些书上或网上的例题,但是都出这样的错误。
/*
* HelloWorld.java
*
* June 27, 2000
*
* ? Copyright 2000 Motorola, Inc. All Rights Reserved.
* This notice does not imply publication.
*/

package com.mot.j2me.midlets.tutorials;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

/**
* A simple Hello World midlet
*
* @see MIDlet
*/

public class HelloWorld extends MIDlet {
/**
* Main application screen
*/

private Form mainScreen;
/**
* A reference to the Display
*/

private Display myDisplay;
/**
* Creates a screen for our midlet
*/

HelloWorld() {
myDisplay = Display.getDisplay(this);
mainScreen = new Form("Hello World");
/*
* Create a string item
*/
StringItem strItem = new StringItem
("Hello", "This is a J2ME MIDlet.");
mainScreen.append(strItem);
}

/**
* Start the MIDlet
*/
public void startApp() throws MIDletStateChangeException {
myDisplay.setCurrent(mainScreen);
}

/**
* Pause the MIDlet
*/
public void pauseApp() {
}

/**
* Called by the framework before the application is unloaded
*/
public void destroyApp(boolean unconditional) {
}

}

tiger_lei 2001-09-27
  • 打赏
  • 举报
回复
want details

13,097

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧