由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Question about displaying Chinese
相关主题
help "java.lang.NoSuchMethodError"请问一个最初级问题
怎麼得到字符串中的raw bytes?请帮忙看看这个编译错误
急问:java如何处理中文字符大侠帮忙看看这个code为什么在jdk1。5下面不能运行
网上找了贪吃蛇的程序,请问如何run这些程序?也问一个Eclipse的问题
NoClassDefFoundErrorJava fun
如何从java中调用MatlabEclipse编译老是出问题啊。。file not found exception
库里有一个函数名也叫Time实实在在受不了了,还是来这里求教!
问个java on linux的奇怪问题显示email中文的问题
相关话题的讨论汇总
话题: chinese话题: jlabel话题: display话题: string话题: s1
进入Java版参与讨论
1 (共1页)
e**n
发帖数: 10
1
I wrote a small program to display Chinese, but I can not display Chinese
correct.
Here is my code:
try
{
String s1 = "讨论";
JLabel jlTemp = new JLabel("Display: " + s1);
}
catch(Exception e)
{
}
In this case, the JLabel display garbage on the screen.
try
{
String s1 = "讨论";
String s2 = new String(s1.getBytes(), "GBK");
JLabel jlTemp = new JLabel("Display: " + s2);
}
catch(Exception e)
}
In this case, the JLabel display "????" on the screen.
Can someone tell me where my proble
f********h
发帖数: 149
2
look at the font property file under $JAVA_HOME/jre/lib
you need to specify the chinese font there.
google bah.

【在 e**n 的大作中提到】
: I wrote a small program to display Chinese, but I can not display Chinese
: correct.
: Here is my code:
: try
: {
: String s1 = "讨论";
: JLabel jlTemp = new JLabel("Display: " + s1);
: }
: catch(Exception e)
: {

e**n
发帖数: 10
3
The font property is not the problem.
I found an example using Chinese in "\u6839\u636e" format. If I use s1 =
"\u6839\u636e" in my program, I can display it in Chinese correctly. But the
problem is, how am I going to implement? How can I convert all Chinese into
\uxxxx format?

【在 f********h 的大作中提到】
: look at the font property file under $JAVA_HOME/jre/lib
: you need to specify the chinese font there.
: google bah.

f********h
发帖数: 149
4
did you set up correct encoding in your code?

【在 e**n 的大作中提到】
: The font property is not the problem.
: I found an example using Chinese in "\u6839\u636e" format. If I use s1 =
: "\u6839\u636e" in my program, I can display it in Chinese correctly. But the
: problem is, how am I going to implement? How can I convert all Chinese into
: \uxxxx format?

w********c
发帖数: 2632
5
native2ascii

Chinese

【在 e**n 的大作中提到】
: The font property is not the problem.
: I found an example using Chinese in "\u6839\u636e" format. If I use s1 =
: "\u6839\u636e" in my program, I can display it in Chinese correctly. But the
: problem is, how am I going to implement? How can I convert all Chinese into
: \uxxxx format?

e***g
发帖数: 158
6
then it's source file encoding problem. your editor uses one encoding to
to save file, probably GB, but javac doesn't know that. check javac
command line options to tell it the encoding.

【在 e**n 的大作中提到】
: The font property is not the problem.
: I found an example using Chinese in "\u6839\u636e" format. If I use s1 =
: "\u6839\u636e" in my program, I can display it in Chinese correctly. But the
: problem is, how am I going to implement? How can I convert all Chinese into
: \uxxxx format?

t****s
发帖数: 141
7
Also, unless you specify it, default encoding is based on your platform.

【在 e***g 的大作中提到】
: then it's source file encoding problem. your editor uses one encoding to
: to save file, probably GB, but javac doesn't know that. check javac
: command line options to tell it the encoding.

1 (共1页)
进入Java版参与讨论
相关主题
显示email中文的问题NoClassDefFoundError
问一个Java题如何从java中调用Matlab
新手求助,急急急!!!库里有一个函数名也叫Time
Re: 怎样不用main(String args[])输出"hello worl问个java on linux的奇怪问题
help "java.lang.NoSuchMethodError"请问一个最初级问题
怎麼得到字符串中的raw bytes?请帮忙看看这个编译错误
急问:java如何处理中文字符大侠帮忙看看这个code为什么在jdk1。5下面不能运行
网上找了贪吃蛇的程序,请问如何run这些程序?也问一个Eclipse的问题
相关话题的讨论汇总
话题: chinese话题: jlabel话题: display话题: string话题: s1